Service - Translations: Difference between revisions
No edit summary |
No edit summary |
||
Line 20: | Line 20: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
configKey: "GraphNodeLabelSuffix" | |||
configTag: "Translation" | |||
configValue: xxx // eg: "translation" | |||
} | |||
</syntaxhighlight> | |||
* combines with subject label/s to create translation node label | |||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
configKey: "GraphRelationshipTypeSuffix" | |||
configTag: "Translation" | |||
configValue: xxx // eg: "Translation" | |||
} | |||
</syntaxhighlight> | |||
* 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 = | = Graph database = |
Revision as of 12:19, 5 June 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
- nodeIdentifierProperties: up to the object and the service that manages it, not set by translation service
- nodeProperties: Can store additional properties, not set by translation service
- cannot be removed
- immutable, no properties added/removed/changed
translation
Previously planned a unique translationId, but in neo4j feel the text+languageCode properties can be used as the unique id, then planned to tie each translation to a unique subject object (to pinpoint a specific translation would need the subjects identifiers and the translations text and languageCode).
Current design is the translation text is the unique identifier for a translation node, and any number of subjects, or languages, can point to it, relationships define its different applications.
- nodeIdentifierLabel: set in NodeLib.js, "translation"
- nodeIdentifierProperties: text
- cannot be removed
- immutable, no properties added/removed/changed
Relationships
has{translation}
- All possible translations are linked to their subjectId with a relationship of this type
- immutable
has{languageCode}{translation}
- All possible translations for each languageCode are linked to their subjectId with a relationship of this type
- When recalculating current translation for a languageCode 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{languageCode}{translation}
- Matches one translation as the currently used translation for one languageCode
- Only one should exist per subject node per languageCode
- Languages that have no translations will not have one
- Can be removed and replaced when RecalculateCurrentTranslation
default{translation}
- Used when no desired languageCode 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 languageCode found as the default
SQS queues
RecalculateCurrentTranslation
Add to this queue the subject nodeIdentifierLabels, subject nodeIdentifierProperties, languageCode
- subject nodeIdentifierLabels
- subject nodeIdentifierProperties
- languageCode: see below
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