In this document:
Some strings in different contexts can require different translations. If you need to provide a context specific translation, the msgid must contain both, the translation string and the context in the form of “<translation string>_<context>”. For example, if the translation string is “Please wait” and the context is “Submit”, the respective msgid must be “Please wait_Submit”. A context can be created by the system for predefined translations. A package developer can create custom contexts as well.
Some default strings used in APS JS SDK widgets have predefined translations into the following languages:
de_DE - German
es_ES - Spanish
fr_FR - French
ja_JP - Japanese
nl_NL - Dutch
pt_BR - Brazilian Portuguese
ru_RU - Russian
The following strings have predefined translations:
WIDGET |
TRANSLATION STRING |
CONTEXT |
DEFAULT VALUE |
---|---|---|---|
Please wait |
apsButton |
Please wait |
|
Select date |
apsCalendar |
Select date |
|
No item(s) found |
apsGrid |
No item(s) found |
|
Number of entries per page: |
apsGrid |
Number of entries per page: |
|
item(s) total |
apsGrid |
item(s) tota |
|
Search |
apsGrid |
Search |
|
Reset Search |
apsGrid |
Reset Search |
|
First |
apsGrid |
First |
|
Last |
apsGrid |
Last |
|
All |
apsGrid |
All |
|
Pages |
apsGrid |
Pages |
|
Settings |
apsListSwitcher |
Settings |
|
Sorting: |
apsListSwitcher |
Sorting: |
|
In ascending order: A to Z |
apsListSwitcher |
In ascending order: A to Z |
|
In descending order: Z to A |
apsListSwitcher |
In descending order: Z to A |
|
List View Mode: |
apsListSwitcher |
List View Mode: |
|
Active List |
apsListSwitcher |
Active List |
|
Classic List |
apsListSwitcher |
Classic List |
|
Reset password |
apsPassword |
Reset password |
|
Hide password |
apsPassword |
Hide password |
|
Show password |
apsPassword |
Show password |
|
Password does not match |
apsPassword |
Password does not match |
|
Reset |
apsPassword |
Reset |
|
The value entered is not valid. |
apsPassword |
The value entered is not valid. |
|
This value is required. |
apsPassword |
This value is required. |
|
completed |
apsProgressBar |
completed |
|
This value is out of range. |
apsSlider |
This value is out of range. |
|
The value entered is not valid. |
apsSlider |
The value entered is not valid. |
|
This value is required. |
apsSlider |
This value is required. |
|
ON |
apsSwitch |
ON |
|
OFF |
apsSwitch |
OFF |
|
Not valid value |
apsTextBox |
Not valid value |
|
The value entered is not valid. |
apsTextBox |
The value entered is not valid. |
|
This value is required. |
apsTextBox |
This value is required. |
|
All symbols required. |
apsTextBox |
All symbols required. |
|
Please wait |
apsToolbarButton |
Please wait |
|
Please wait |
apsToolsItem |
Please wait |
Note
The predefined translations are not present in po
files. If you need to substitute a predefined
translation with your own custom string, you need to manually create the respective msgid and msgstr
pair in the proper po
file. The msgid string must include the respective context
as presented in the above table.
The aps msgmake
command extracts localization data from JavaScript code in *.html
and *.js
files
used for building UI views. The _()
function
is a hook that makes a string available for translation. For example, _("string to translate")
makes
the aps msgmake
command create the msgid “string to translate” and “msgstr” pair in the PO files.
The aps/i18n
module redefines the window._()
function.
In general, a string may contain mapped parameters that should not be translated. The mapped parameters must be enclosed by a pair of underscores “__”. In the following example, the msgKey string contains parameters whose values must be found in the paramObjects mapping string.
_(msgKey, paramObjects)
The _()
function is used to localize the string @msgKey. For example, @msgKey is actually
a string “Found __itemsCount__ item(s)”.
This string contains the itemsCount parameter, wrapped by a pair of underscores. The parameter is defined
by the mapping string, for example, {“itemsCount”:counter}.
So, if aps msgmake
meets the following code when parsing a JavaScript code:
_("Found __itemsCount__ item(s)", {"itemsCount":itemsCount})
it automatically generates the following pair of records in the PO file:
msgid "Found __itemsCount__ item(s)"
msgstr ""
A translator can manually translate the message in the following way, for example, into Russian:
msgid "Found __itemsCount__ item(s)"
msgstr "Найдено __itemsCound__ элемент(ов)"
If a string translation is context dependent, specify a custom context as in the following example:
title: _("Context specific title", { context: "myOwnContext" })
For each context with the same string, the APS build utility will create a separate msgid and msgstr pair. For the above example, it will be:
msgid "Context specific title_myOwnContext"
msgstr ""
If the same string is used without a context property, a respective msgid will be created without the context property. In the process of building a widget on the client side, the context specific translation takes precedence over the context-less translation.