Changes between Version 17 and Version 18 of Internationalization
- Timestamp:
- Apr 19, 2014, 7:25:42 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Internationalization
v17 v18 48 48 Simply put: '''you cannot'''. 49 49 50 You can call any of the global internationalization functions described below, however, strings passed to these functions are not parsed by the message extraction system, which means that translators won’t be able to actually translate the string.51 52 Move any !JavaScript code that requires internationalization of “hard-coded” strings into a function of a separate !JavaScript file. The message extraction systemwill successfully extract !JavaScript strings from !JavaScript files. You can then call that function from your GUI file. For example:50 You can call any of the global internationalization functions described below, however, strings passed to these functions are not parsed by the [wiki:Message_Extraction message extraction tool], which means that translators won’t be able to actually translate the string. 51 52 Move any !JavaScript code that requires internationalization of “hard-coded” strings into a function of a separate !JavaScript file. The message extraction tool will successfully extract !JavaScript strings from !JavaScript files. You can then call that function from your GUI file. For example: 53 53 54 54 '''Original:''' … … 151 151 = Internationalizing !JavaScript Simulation Files = 152 152 153 Internationalizing js simulation files isn't easy, as the simulation is supposed to be deterministic, and completely equal between different players in a game (which may use different locales). That's why the simulation may only mark strings for translation (those strings will can found by the message extracting tool), and the actual translation has to happen in the unsynced GUI files.153 Internationalizing js simulation files isn't easy, as the simulation is supposed to be deterministic, and completely equal between different players in a game (which may use different locales). That's why the simulation may only mark strings for translation (those strings will can found by the [wiki:Message_Extraction message extracting tool]), and the actual translation has to happen in the unsynced GUI files. 154 154 155 155 Marking a string for translation is done with the {{{markForTranslation(message)}}} and {{{markForTranslationWithContext(context, message)}}} functions. … … 172 172 Internationalizing strings from data files that are loaded by !JavaScript files is a two-step process. You must: 173 173 174 1. Configure the [wiki: Implementation_of_Internationalization_and_Localization#MessageExtraction message extraction system] to extract the translatable strings from the data file.174 1. Configure the [wiki:Message_Extraction message extraction] to extract the translatable strings from the data file. 175 175 1. Use an internationalization function on the !JavaScript side after you load the data file. 176 176 177 177 == Configuring the Message Extraction System for Data Files == 178 Our message extraction systemcurrently supports extracting data strings from:178 Our [wiki:Message_Extraction message extraction tool] currently supports extracting data strings from: 179 179 180 180 * '''Plain text files (.txt)'''. The content of plain text files can be extracted line by line. Paragraphs in these plain text files should not contain line breaks, otherwise each line is extracted as a separate message, which is not translator-friendly. … … 184 184 * Strings from JSON data defined within an XML element. 185 185 186 To 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#MessageExtraction message extraction system documentation.]186 To 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 [wiki:Message_Extraction Message Extraction]. 187 187 188 188 == Internationalizing Content that !JavaScript Files Load from Data Files == 189 Once the message extraction systemis 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.189 Once the message extraction 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. 190 190 191 191 If the !JavaScript file obtains the data as string that contains the complete message to translate, you can simply pass a variable that contains the translatable string to a global internationalization function such as `translate()` or `translateWithContext()`. … … 223 223 }}} 224 224 225 It will translate "translatedObject1" using a certain context, and every string in the list of "translatedObject2" also with the same context, after which the list will also be joined with a locali sed connector (", " in English). So the result could be225 It will translate "translatedObject1" using a certain context, and every string in the list of "translatedObject2" also with the same context, after which the list will also be joined with a localized connector (", " in English). So the result could be 226 226 227 227 {{{