Difference between revisions of "Extensions.I18n.Translate"

From emotive
Jump to navigation Jump to search
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:i18n]]
+
{{DISPLAYTITLE:  '''Translate'''}}[[Category:i18n]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | Translate | Returns a localized string from a '''TranslationKey''' | [[Term]] | [[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);
+
StringTerm I18n.Translate(TranslationKeyTerm translationKey, {Term[ ] arguments});
 
</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 will return a localized string in the current user language.
  
{{TermReturnValue| [[String]] | Localized string in the current user language.}}
+
{{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]] will be thrown.}}
 +
 
 +
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.String|String]] | Localized string in the current user language.}}
  
 
== Properties ==
 
== Properties ==
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| TrasnlationKey | [[TrasnlationKey]] | [[Term]] | - | [1] | A unique key that the system uses to locate a translation into internal database.}}
+
{{TableRowPropertie1| TranslationKey | [[Extensions.I18n.TranslationKey|TranslationKey]] | [[Term]] | - | [1] | This element represents a unique key that the system will use to search its internal database for a translation.}}
 +
{{TableRowPropertie2| Arguments| [[Term]] | [[Term]] | - | [0..1] | This optional element represents a list of arguments for the translation.}}
 
|}
 
|}
  
== Examples ==
+
== OTL Examples ==
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 +
/// Local Declarations
 +
 
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>
  
 
== See also ==
 
== See also ==
[[CreateTranslationKey]] <br/>
+
[[Extensions.I18n.CreateTranslationKey|CreateTranslationKey]] <br/>
[[TranslateToLocale]] <br/>
+
[[Extensions.I18n.TranslateToLocale|TranslateToLocale]] <br/>
[[CompareUntranslatedString]]
+
[[Extensions.I18n.CompareUntranslatedString|CompareUntranslatedString]]

Latest revision as of 02:42, 13 September 2019

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(TranslationKeyTerm translationKey, {Term[ ] arguments});

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 will return a localized string in the current user language.

Icons Note.png 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 will 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
TranslationKey TranslationKey Term - [1] This element represents a unique key that the system will use to search its internal database for a translation.
Arguments Term Term - [0..1] This optional element represents a list of arguments for the translation.

OTL Examples

/// Local Declarations

I18n.TranslationKey TranslationKey1;
String String1 = "";

/// Flow

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

See also

CreateTranslationKey
TranslateToLocale
CompareUntranslatedString