Translations

Tyranid Translations provide the ability to perform both white labeling, internationalization, and localization of various types of string data, including labels, names, data values, custom terms, and so on.

Built-in Translation

Translations within Tyranid are designed to be supported without having to do any additional work on the part of the developer -- they are "built-in". This is accomplished by having "language string codes" automatically generated based on metadata and IDs in the majority of cases.

However, for cases where you need a translatable term that is not associated with a particular piece of data or metadata, this is handled by Terms.

Locale and White Labels

White labeling is translation process where application and data terms can be modified to be specific for an organization. For example, an application might by default want to label a field as "Manager" while some specific organization might want to see that field show up as "Leader".

Tyranid enhances the concept of a local to also optionally include an organization. This confers the ability to white label data by providing an organization along with the locale when defining a translation.

This means that white labels can also be internationalized because both an organization and a locale can be provided in a context.

Translations

Translations are stored in the tyrTranslation collection. For example:

Translation Description
TyrTranslation.insert({
  _id: `${User.id}/name`,
  locale: 'ko_KR',
  value: '컴퓨터'
});
Inserts a Korean translation for the name field in the User collection.
TyrTranslation.insert({
  _id: `${User.id}/name`,
  organization: currentUser.organization,
  locale: 'ko_KR',
  value: 'Thinking Machine'
});
Inserts a white label in the default language.
TyrTranslation.insert({
  _id: `${User.id}/name`,
  organization: currentUser.organization,
  value: '사고 기계'
});
Inserts a white label in the korean language.

Translation IDs

The format of the tyrTranslation._id field is:

UID[/path]

For example:
Translation IDMeans
u00The label for the User collection.
u00/nameThe label for the User collection's name field.
u00/name/helpThe tooltip for the User collection's name field.
or3/orders.amountThe label for the Order collection's amount field that is embedded in an orders array.
u005567f2a5387fa974fc6f3a42/nameThe value of the name field for the user with ID 5567f2a5387fa974fc6f3a42.
_tmwidgetNameThe value of the widgetName term (_tm is the UID for the Term collection).

Terms

Terms are stored in the tyrTerm collection.

Tyr.$ can be used to automatically translate the default string into another context. For example:

TyrTerm.insert({
  _id: 'applicationName',
  value: 'My Default Application',
  help: 'This contains the name of the default application.'
});

...
        
const value = Tyr.$`Welcome to $$applicationName!`;

Default values provided in metadata automatically are processed by Tyr.$. The following example shows how terms can be used in regular metadata:

new Tyr.Collection({
  name: 'Widget',
  label: 'A $$widgetName',
  ...,
  fields: {
    ...,
    name: {
      is: 'string',
      label: '$$widgetName Label', 
      help: 'This contains the name of your $$widgetName.'
  }
});

Automatic Translations

Accessing white-labelable fields will be automatically translated into the current user context if one is available on Tyr.local.

For example, accessing Tyr.collections.User.fields.name.label will automatically return any translation relevant to the current user for the label for User name field.