-
Notifications
You must be signed in to change notification settings - Fork 29
PKLOC.addTranslation
kerrishotts edited this page Nov 12, 2012
·
1 revision
(part of PKLOC)
Return Type: void
Parameters: locale, key, value
Stores a translation into the PKLOC.localizedText dictionary. If a particular locale,key, and value pair exist, the value is overwritten.
For example:
PKLOC.addTranslation ( "en", "HOW_ARE_YOU?", "How are you?" );
PKLOC.addTranslation ( "fr", "HOW_ARE_YOU?", "Comment ça va?" );
PKLOC.addTranslation ( "en", "MY_NAME_IS_%1", "My name is %1");
PKLOC.addTranslation ( "es", "MY_NAME_IS_%1", "Me llamo %1");
PKLOC.addTranslation ( "en", "COMPUTER", "Computer");
PKLOC.addTranslation ( "es", "COMPUTER", "Ordenador");
PKLOC.addTranslation ( "es-MX", "COMPUTER", "Computadora");
- Use as high of a locale as possible -- that is, for "English" use "en" rather than "en-US". Use country-specific locales only when a translation needs to be specific to the country.
- If the key is not found, it is returned as-is. When attempting to determine if a locale is missing a translation, the capitalization of the keys in the above examples makes it easy to tell if one is missed.
- There is no requirement that the key be one word -- you can use spaces if you want.
- Any number preceded by a percent sign is treated as a substitution variable when used with
__T
. While it is not a requirement that it be used in the key (it only is required to exist in the value), it helps document the code to use it in both the key and value. - There is no requirement that the key and value be directly related. You could have the key be "APP_TITLE" and the value be the title of your app. For that matter, you could have the key be "1234" and the value be "cow". It is suggested, however, that the key describe the value in some manner.
0.1 Introduced
0.2 Docs Valid