Difference between revisions of "Extensions.I18n.Translate"

From emotive
Jump to navigation Jump to search
Line 1: Line 1:
{{DISPLAYTITLE:  '''Translate '''}}[[Category:i18n]]
+
{{DISPLAYTITLE:  '''Translate'''}}[[Category:i18n]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | Translate | Returns a localized string from a '''TranslationKey''' | [[Term]] | [[Extensions.I18n|OTX i18n extension]] | [[Translation related terms]] | - | - }}
+
{{ClassificationActivity | Translate | Returns a localized string from a '''TranslationKey''' | [[Term]] | [[Extensions.I18n|OTX i18n extension]] | [[Extensions.I18n#Terms|Translation related terms]] | - | - }}
  
 
== OTL Syntax ==
 
== OTL Syntax ==
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
StringTerm = I18n.Translate(TrasnlationKey, Arguments);
+
StringTerm = I18n.Translate(TrasnlationKey, TranslationArguments);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Description ==
 
== Description ==
The '''Translate''' term accepts a ''TranslationKey'' argument and returns a localized string in the current user language.
+
The '''Translate''' term accepts a ''TranslationKey'' which may be supplemented by additional translation arguments for message parameter substitution (if required by the associated thesaurus entry). It shall return a localized string in the current user language.
 +
 
 +
{{Note|NOTE – If the format message is invalid, or if an argument in the arguments element is not of the type expected
 +
by the format element(s) that use it, an [[Extensions.I18n.I18nException|i18nException]] shall be thrown.}}
  
 
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.String|String]] | Localized string in the current user language.}}
 
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.String|String]] | Localized string in the current user language.}}
Line 16: Line 19:
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| TrasnlationKey | [[Extensions.I18n.TranslationKey|TranslationKey]] | [[Term]] | - | [1] | A unique key that the system uses to locate a translation into internal database.}}
+
{{TableRowPropertie1| TrasnlationKey | [[Extensions.I18n.TranslationKey|TranslationKey]] | [[Term]] | - | [1] | This element represents a unique key that the system shall use to search its internal database for a translation.}}
 +
{{TableRowPropertie2| Arguments| [[TranslationArguments]] | - | - | [0..1] | This optional element represents a list of arguments for the translation.}}
 
|}
 
|}
  
Line 22: Line 26:
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
I18n.TranslationKey TranslationKey1;
 
I18n.TranslationKey TranslationKey1;
String result;
+
String String1 = "";
 +
 
 +
/// Flow
  
 
TranslationKey1 = I18n.CreateTranslationKey("TEXT_1");
 
TranslationKey1 = I18n.CreateTranslationKey("TEXT_1");
result = Translate(TranslationKey, null);
+
String1 = I18n.Translate(TranslationKey1);
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 10:31, 28 September 2018

Classification

Name Translate
Short Description Returns a localized string from a TranslationKey
Class Term
Extension OTX i18n extension
Group Translation related terms
Exceptions -
Checker Rules -
Standard Compliant Yes

OTL Syntax

StringTerm = I18n.Translate(TrasnlationKey, TranslationArguments);

Description

The Translate term accepts a TranslationKey which may be supplemented by additional translation arguments for message parameter substitution (if required by the associated thesaurus entry). It shall return a localized string in the current user language.

Icons Note.png NOTE – If the format message is invalid, or if an argument in the arguments element is not of the type expected

by the format element(s) that use it, an i18nException shall be thrown.

Return Value

The Term returns the value, see table below.

Icons Note.png In OTX, Terms are categorized according to its return data type!
Data Type Description
String Localized string in the current user language.

Properties

Name Data Type Class Default Cardinality Description
TrasnlationKey TranslationKey Term - [1] This element represents a unique key that the system shall use to search its internal database for a translation.
Arguments TranslationArguments - - [0..1] This optional element represents a list of arguments for the translation.

OTL Examples

I18n.TranslationKey TranslationKey1;
String String1 = "";

/// Flow

TranslationKey1 = I18n.CreateTranslationKey("TEXT_1");
String1 = I18n.Translate(TranslationKey1);

See also

CreateTranslationKey
TranslateToLocale
CompareUntranslatedString