Service - Translations: Difference between revisions
No edit summary |
|||
Line 51: | Line 51: | ||
* nodeIdentifierLabels: matches that specific object being translated, eg: catalogName | * nodeIdentifierLabels: matches that specific object being translated, eg: catalogName | ||
* | * nodeUniqueIdProperties: up to the object and the service that manages it, not set by translation service | ||
* nodeProperties: (not set by translation service) | * nodeProperties: (not set by translation service) | ||
Line 64: | Line 64: | ||
# configKey: "GraphNodeLabel", configTag: "translation" | # configKey: "GraphNodeLabel", configTag: "translation" | ||
===== | ===== nodeUniqueIdProperties ===== | ||
* translationId: (random UUID) | * translationId: (random UUID) | ||
Line 99: | Line 99: | ||
== RecalculateCurrentTranslation == | == RecalculateCurrentTranslation == | ||
Add to this queue the subject nodeIdentifierLabels, subject | Add to this queue the subject nodeIdentifierLabels, subject nodeUniqueIdProperties, languageCode, translationId: | ||
* subject nodeIdentifierLabels: Label/s for the entity being translated, eg: ''categoryName'' | * subject nodeIdentifierLabels: Label/s for the entity being translated, eg: ''categoryName'' | ||
* subject | * subject nodeUniqueIdProperties: used to find the specific subject node | ||
* languageCode: see below | * languageCode: see below | ||
* (?not needed?) translationId: is the unique property of the translation node | * (?not needed?) translationId: is the unique property of the translation node |
Revision as of 08:34, 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: "GraphNodeLabelSuffix"
configTag: "Translation"
configValue: xxx // eg: "translation"
}
- combines with subject label/s to create translation node label
{
configKey: "GraphRelationshipTypeSuffix"
configTag: "Translation"
configValue: xxx // eg: "Translation"
}
- combines with NPM module - izara-shared#constants has and current to create the various translation relationship types
- Uppercase so joins with other wording correctly
Graph database
Service - Translations Graph
Nodes
(subject nodes)
- nodeIdentifierLabels: matches that specific object being translated, eg: catalogName
- nodeUniqueIdProperties: 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
- 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"
nodeUniqueIdProperties
- 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 nodeUniqueIdProperties, languageCode, translationId:
- subject nodeIdentifierLabels: Label/s for the entity being translated, eg: categoryName
- subject nodeUniqueIdProperties: 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)
- Label example: NPM module - izara-market-shared#CatalogManagerLib.constants.sysTxtCatalogManager ("sysTxtCatalogManager")
- UniqueIdProperty example: "CatalogName", value: NPM module - izara-market-shared#CatalogManagerLib.constants.CatalogStandard.catalogName