Service - Translations: Difference between revisions
No edit summary |
No edit summary |
||
Line 43: | Line 43: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
nodeLabel: "{TranslationLib. | nodeLabel: "{TranslationLib.TRANSLATION_GRAPH_NODE_LABEL}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", //eg: translationLink | ||
schema: { | schema: { | ||
identifier: true, | identifier: true, | ||
Line 62: | Line 62: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
nodeLabel: {TranslationLib. | nodeLabel: {TranslationLib.TRANSLATION_GRAPH_NODE_LABEL}, | ||
schema: { | schema: { | ||
identifier: true, | identifier: true, | ||
Line 92: | Line 92: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
relationshipType: " | relationshipType: "{TranslationSharedLib.TRANSLATION_HAS_LINK_GRAPH_REL_TYPE_PREFIX}{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", // eg: has_catalogNameLink | ||
schema: { | schema: { | ||
immutable: true, | immutable: true, | ||
Line 106: | Line 106: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
relationshipType: " | relationshipType: "{TranslationSharedLib.TRANSLATION_HAS_LINK_GRAPH_REL_TYPE_PREFIX}{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", // has_eng_catalogNameLink | ||
schema: { | schema: { | ||
immutable: true, | immutable: true, | ||
Line 121: | Line 121: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
relationshipType: " | relationshipType: "{TranslationSharedLib.TRANSLATION_DEFAULT_LINK_GRAPH_REL_TYPE_PREFIX}{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", | ||
schema: { | schema: { | ||
elementCanBeRemoved: true, | elementCanBeRemoved: true, | ||
Line 138: | Line 138: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
relationshipType: " | relationshipType: "{TranslationSharedLib.TRANSLATION_CURRENT_LINK_GRAPH_REL_TYPE_PREFIX}{languageCode}_{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", | ||
schema: { | schema: { | ||
elementCanBeRemoved: true, | elementCanBeRemoved: true, | ||
Line 155: | Line 155: | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
{ | { | ||
relationshipType: " | relationshipType: "{RelationshipLib.TRANSLATION_IS_TRANSLATION_GRAPH_REL_TYPE}", | ||
schema: { | schema: { | ||
elementCanBeRemoved: false, | elementCanBeRemoved: false, |
Revision as of 02:39, 20 August 2021
Overview
Service manages language translations.
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"
}
LogicalResults
Stores results for any requests to perform logical searches on media links
{
resultId: xxx // eg: filterMainId for a single logical element
dataId: xxx // one translationId
}
- partition key: resultId
- sort key: dataId
Graph database
Service - Translations Graph
Nodes
{
nodeLabel: "{TranslationLib.TRANSLATION_GRAPH_NODE_LABEL}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", //eg: translationLink
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
translationLinkId: {
identifier: true, // create unique id from request details
}
},
}
}
- creates a link between a subject node and a translation text
- the relationships that connect the subject to the translationLink define what is being translated (one subject may have multiple texts that need to be translated), and what language
- when recalculating current translation for a languageCode we add the calculated weighted value to this node as a property
{
nodeLabel: {TranslationLib.TRANSLATION_GRAPH_NODE_LABEL},
schema: {
identifier: true,
restrictProperties: true,
restrictRelationships: true,
properties: {
text: {
identifier: true,
},
},
}
}
(subject nodes)
Subject node schemas are managed by each service that needs translations, normally as a basic schema with identifier properties only.
- nodeIdentifierLabels: matches that specific object being translated, eg: catalog
- nodeIdentifierProperties: matches that specific object being translated, eg: catalogId
- nodeProperties: Can store additional properties, not set by translation service
- node schema should set identifier = true, immutable = true (which includes elementCanBeRemoved = false)
Relationships
- {textTag} is the name of the text being translated, eg a Catalog subject node will have a textTag "catalogName"
- Relationship schema for {textTag} relationships are managed by each service that needs translations
{
relationshipType: "{TranslationSharedLib.TRANSLATION_HAS_LINK_GRAPH_REL_TYPE_PREFIX}{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", // eg: has_catalogNameLink
schema: {
immutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- every translationLink will have this relationship
{
relationshipType: "{TranslationSharedLib.TRANSLATION_HAS_LINK_GRAPH_REL_TYPE_PREFIX}{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}", // has_eng_catalogNameLink
schema: {
immutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- every translationLink for the specified languageCode will have this relationship
- is never removed, but those with low weights can be ignored over time
{
relationshipType: "{TranslationSharedLib.TRANSLATION_DEFAULT_LINK_GRAPH_REL_TYPE_PREFIX}{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}",
schema: {
elementCanBeRemoved: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- sets the default translationLink to use when no translationLink for the requested language/s exist
- can be changed but each subject/textTag must have 1
- initially set to the first translation created, later can move it around eg to English if English gets added later
- could create logic that goes through a sorted list of languages and applies the first languageCode found as the default
{
relationshipType: "{TranslationSharedLib.TRANSLATION_CURRENT_LINK_GRAPH_REL_TYPE_PREFIX}{languageCode}_{textTag}{TranslationSharedLib.TRANSLATION_LINK_GRAPH_TAG}",
schema: {
elementCanBeRemoved: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
- the currently used translationLink for the specified languageCode
- only one should exist per subject node/textTag per languageCode
- languages that have no translations will not have one
- can be removed/added when RecalculateCurrentTranslation
{
relationshipType: "{RelationshipLib.TRANSLATION_IS_TRANSLATION_GRAPH_REL_TYPE}",
schema: {
elementCanBeRemoved: false,
allPropertiesImmutable: true,
restrictProperties: true,
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
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