Service - Translations: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
Line 23: Line 23:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configKey: "GraphTag"
configKey: "GraphNodeLabel"
configTag: "translation"
configTag: "translation"
configValue: xxx // eg: "translation"
configValue: xxx // eg: "translation"
Line 31: Line 31:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
configKey: "GraphTag"
configKey: "GraphRelationshipType"
configTag: "possiblyTranslatesTo"
configTag: "Translation"
configValue: xxx // eg: "possiblyTranslatesTo"
configValue: xxx // eg: "Translation"
}
}
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="JavaScript">
* combines with [[NPM module - izara-shared#constants]] ''has'' and ''current'' to create the various translation relationship types
{
* Uppercase so joins with other wording correctly
configKey: "GraphTag"
 
configTag: "translatesTo"
= Graph database =
configValue: xxx // eg: "translatesTo"
 
}
== [[Service - Translations Graph]] ==
</syntaxhighlight>


<syntaxhighlight lang="JavaScript">
=== Nodes ===
{
configKey: "GraphTag"
configTag: "defaultTranslatesTo"
configValue: xxx // eg: "defaultTranslatesTo"
}
</syntaxhighlight>


= Neptune graph database =  
==== (subject nodes) ====


== [[Service - Translations Graph]] ==
* nodeIdentifierLabels: matches that specific object being translated, eg: catalogName
* nodeUniqueIdPropertyNames: up to the object and the service that manages it, not set by translation service
* nodeProperties: (not set by translation service)


=== Vertices ===
==== translation ====


==== (subject vertices) ====
===== nodeIdentifierLabels =====  


vertexId: {tag}_{uniqueId} (not set by translation service)
Three labels for future query possibilities


Properties: (not set by translation service)
# combine subject node label with language code and config table: configKey: "GraphNodeLabel", configTag: "translation"
# combine subject node label with config table: configKey: "GraphNodeLabel", configTag: "translation"
# configKey: "GraphNodeLabel", configTag: "translation"


==== translation ====
===== nodeUniqueIdPropertyNames =====


vertexId: translation_{uuid}
* translationId: (random UUID)


Properties:
===== nodeProperties =====


# translation
* text - the text of the translation
#: the text of the translation
* language - language code


=== Edges ===
=== Relationships ===


==== possiblyTranslatesTo ====
==== has{language}{translation} ====


* All possible translations are linked to their subjectId with an edge of this type
* All possible translations are linked to their subjectId with an relationship of this type
* A users support for a translation is connected to this edge (or to the translation vertex if unable to link to an edge)
* When recalculating current translation for a language for each has..translation relationship we add the calculated weighted value to this relationship
* When recalculating current translation for a language we add the calculated weighted value for each possible translation to this edge as a property
* This relationship is never removed, but those with low weights can be ignored over time
* This type of edge is never removed, but those with low weights can be ignored over time


==== translatesTo ====
==== current{language}{translation} ====


* Matches one possible translation as the currently used translation for one language
* Matches one translation as the currently used translation for one language
* Only one should exist per subjectId per language
* Only one should exist per subject node per language
* Languages that have no translations will not have one
* Languages that have no translations will not have one
* Can be removed and replaced when RecalculateCurrentTranslation
* Can be removed and replaced when RecalculateCurrentTranslation


==== defaultTranslatesTo ====
==== default{translation} ====


* Used when no desired language translation exists
* Used when no desired language translation exists
* Initially set to the first translation created
* Initially set to the first translation created, later can move it around eg to English if English gets added later
* Only one should exist per subjectId
* Only one should exist per subject node
* Can create admin logic that goes through a sorted list of languages and applies the first language found as the default
* Can create admin logic that goes through a sorted list of languages and applies the first language found as the default


Line 101: Line 97:
== RecalculateCurrentTranslation ==
== RecalculateCurrentTranslation ==


Add to this queue the translationLabel, languageCode, subjectId, translationId:
Add to this queue the subject nodeIdentifierLabels, subject nodeUniqueIdPropertyNames, languageCode, translationId:


* translationLabel: Name for the entity being translated, eg: ''categoryName'', is used to create vertex and edge labels in Translations graph database
* subject nodeIdentifierLabels: Label/s for the entity being translated, eg: ''categoryName''
* subject nodeUniqueIdPropertyNames: used to find the specific subject node
* languageCode: see below
* languageCode: see below
* subjectId: is the vertex id in the Translations graph database for the entity that has a relationship with the translation, eg catalogCategory{unique identifier}
* (?not needed?) translationId: is the unique property of the translation node
* translationId: is the vertex id in the Translations graph database for the translation, eg translation{random uuid}


This queue does not have a Lambda trigger, we could poll it when resource costs really cheap as it is low importance (and/or have an API endpoint that polls and processes a batch).
This queue does not have a Lambda trigger, we could poll it when resource costs really cheap as it is low importance (and/or have an API endpoint that polls and processes a batch).
Line 113: Line 109:


Considering using ISO 639-3 codes and designing a way to substring them to automatically go up the hierarchy if no lower level variants match, an alternative would be to allow users to create ordered lists of preferred translations and share these.
Considering using ISO 639-3 codes and designing a way to substring them to automatically go up the hierarchy if no lower level variants match, an alternative would be to allow users to create ordered lists of preferred translations and share these.
= Translation graph relationships/edges =
Links between possible translations and the object they are translating are stored in the Translations graph database as edges. Each possible translation is a vertex.


= How translations are found for users =
= How translations are found for users =


Plan is to allow users to create ordered lists of prefered languages (and perhaps automatic translating as a last option?), these lists can be shared, and new users are automatically set to a list depending on their location when signing up.
Plan is to allow users to create ordered lists of prefered languages (and perhaps optionally automatic translating as a last option?), and new users are automatically set to a list depending on their location when signing up.


For each text to translate work through the list and find the first matching translation, if none found fall back onto the TranslationDefault option.
For each text to translate: work through the list and find the first matching translation, if none found fall back onto the default option.


Will need to cache results for efficient resource use.
cache results for efficient resource use.


= System text translations =
= System text translations =


System text follows the same Tag + UniqueId system to identify specific translation subjects (one system text output), these are set in npm modules.
System text follows the same Label + UniqueIdProperty system to identify specific translation subjects (one system text output), the labels and unique ids can set in npm modules.


'''Tag''' example: [[NPM module - izara-shared#SharedLib]].constants.systemTextGraphTag
* Label example: hard coded or as a constant in NavBar service: "sysTxtNavBar"
* UniqueIdProperty example: "sysTxtTag", value: "SignOut" (can set as a constant in NavBar service)


'''UniqueId''' example: [[NPM module - izara-market-shared#CatalogManagerLib]].constants.CatalogStandardServiceNameGraphId
* Label example: [[NPM module - izara-market-shared#CatalogManagerLib]].constants.sysTxtCatalogManager ("sysTxtCatalogManager")
* UniqueIdProperty example: "CatalogName", value: [[NPM module - izara-market-shared#CatalogManagerLib]].constants.CatalogStandard.catalogName


= Working documents =
= Working documents =

Revision as of 07:27, 30 May 2021

Overview

Service manages translations in the service.

Repository

https://bitbucket.org/stb_working/translations/src/master/

DynamoDB tables

Standard Config Table Per Service

Configuration tags

{
	configKey: "TranslationsGraphServiceName"
	configTag: "TranslationsGraphServiceName"
	configValue: xxx // eg: "TranslationsGraph"
}
{
	configKey: "GraphNodeLabel"
	configTag: "translation"
	configValue: xxx // eg: "translation"
}
{
	configKey: "GraphRelationshipType"
	configTag: "Translation"
	configValue: xxx // eg: "Translation"
}

Graph database

Service - Translations Graph

Nodes

(subject nodes)

  • nodeIdentifierLabels: matches that specific object being translated, eg: catalogName
  • nodeUniqueIdPropertyNames: up to the object and the service that manages it, not set by translation service
  • nodeProperties: (not set by translation service)

translation

nodeIdentifierLabels

Three labels for future query possibilities

  1. combine subject node label with language code and config table: configKey: "GraphNodeLabel", configTag: "translation"
  2. combine subject node label with config table: configKey: "GraphNodeLabel", configTag: "translation"
  3. configKey: "GraphNodeLabel", configTag: "translation"
nodeUniqueIdPropertyNames
  • translationId: (random UUID)
nodeProperties
  • text - the text of the translation
  • language - language code

Relationships

has{language}{translation}

  • All possible translations are linked to their subjectId with an relationship of this type
  • When recalculating current translation for a language for each has..translation relationship we add the calculated weighted value to this relationship
  • This relationship is never removed, but those with low weights can be ignored over time

current{language}{translation}

  • Matches one translation as the currently used translation for one language
  • Only one should exist per subject node per language
  • Languages that have no translations will not have one
  • Can be removed and replaced when RecalculateCurrentTranslation

default{translation}

  • Used when no desired language translation exists
  • Initially set to the first translation created, later can move it around eg to English if English gets added later
  • Only one should exist per subject node
  • Can create admin logic that goes through a sorted list of languages and applies the first language found as the default

SQS queues

RecalculateCurrentTranslation

Add to this queue the subject nodeIdentifierLabels, subject nodeUniqueIdPropertyNames, languageCode, translationId:

  • subject nodeIdentifierLabels: Label/s for the entity being translated, eg: categoryName
  • subject nodeUniqueIdPropertyNames: used to find the specific subject node
  • languageCode: see below
  • (?not needed?) translationId: is the unique property of the translation node

This queue does not have a Lambda trigger, we could poll it when resource costs really cheap as it is low importance (and/or have an API endpoint that polls and processes a batch).

Language codes

Considering using ISO 639-3 codes and designing a way to substring them to automatically go up the hierarchy if no lower level variants match, an alternative would be to allow users to create ordered lists of preferred translations and share these.

How translations are found for users

Plan is to allow users to create ordered lists of prefered languages (and perhaps optionally automatic translating as a last option?), and new users are automatically set to a list depending on their location when signing up.

For each text to translate: work through the list and find the first matching translation, if none found fall back onto the default option.

cache results for efficient resource use.

System text translations

System text follows the same Label + UniqueIdProperty system to identify specific translation subjects (one system text output), the labels and unique ids can set in npm modules.

  • Label example: hard coded or as a constant in NavBar service: "sysTxtNavBar"
  • UniqueIdProperty example: "sysTxtTag", value: "SignOut" (can set as a constant in NavBar service)

Working documents

Working_documents - Translations