Changes between Version 3 and Version 4 of Internationalization


Ignore:
Timestamp:
Apr 13, 2014, 12:22:19 PM (10 years ago)
Author:
Adrián Chaves
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Internationalization

    v3 v4  
    3939Internationalizing strings from data files that are loaded by !JavaScript files is a two-step process. You must:
    4040
    41  1. Configure the [wiki:Implementation_of_Internationalization_and_Localization#MessageExtractionSystem message extraction system] to extract the strings to translate from the data file.
     41 1. Configure the [wiki:Implementation_of_Internationalization_and_Localization#MessageExtractionSystem message extraction system] to extract the translatable strings from the data file.
    4242 1. Use an internationalization function on the !JavaScript side after you load the data file.
    4343
    44 == Configuring the Message Extraction System for Regular XML Files ==
     44== Configuring the Message Extraction System for Data Files ==
    4545Our message extraction system currently supports extracting data strings from:
    4646
     
    5151   * Strings from JSON data defined within an XML element.
    5252
    53 == Internationalizing Content that !JavaScript Files Load from Regular XML Files ==
    54 TODO: translateObjectKeys
     53To configure the message extraction system to extract strings from a new data file, you must edit the `l10n/messages.json` file of the mod folder. In the `messages.json` file of the main mod, `public`, you can find examples of all the supported types of data extraction. For more information, see the [wiki:Implementation_of_Internationalization_and_Localization#MessageExtractionSystem message extraction system documentation.]
     54
     55== Internationalizing Content that !JavaScript Files Load from Data Files ==
     56Once the message extraction system is properly configured to extract the translatable strings from a data file, translators will be able to translate those strings. But for those translations to be actually used, you must internationalize the !JavaScript that loads or uses the data to translate the loaded data at run time.
     57
     58If the !JavaScript file obtains the data as a string, you can simply pass a variable that contains the translatable string to a global internationalization function such as `translate()` or `translateWithContext()`. If the !JavaScript file obtains the data as an object, you can use the `translateObjectKeys()` global function instead, which expects the object with the data and an array with the names of the object properties that must be translated. For example, from the game code:
     59
     60{{{
     61translateObjectKeys(settings.ais, ["name", "description"]);
     62}}}