Changes between Version 5 and Version 6 of Internationalization
- Timestamp:
- Apr 13, 2014, 1:32:09 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Internationalization
v5 v6 1 [[ TOC]]1 [[PageOutline(1-100, Table of Contents)]] 2 2 3 3 = Internationalizing GUI Files = … … 5 5 To internationalize a caption or tooltip (or any other XML attribute) of a GUI XML `object` element, remove the attribute from the `object` element that contains it, and add a new `translatableAttribute` element within the `object` element that used to contain the old attribute, with the name of the old attribute as the value of the `id` attribute of this new element, and the value of the old attribute as the content of this new element. 6 6 7 ''' Note:'''Use "caption" as id of translatableAttribute to translate the caption of an object element.7 ''' Note:''' Use "caption" as id of translatableAttribute to translate the caption of an object element. 8 8 9 9 || '''Original''' || `<object type="button" tooltip="Adjust game settings.">Options</object>` || … … 25 25 Move any !JavaScript code that requires internationalization of “hard-coded” strings into a function of a separate !JavaScript file. The message extraction system will successfully extract !JavaScript strings from !JavaScript files. You can then call that function from your GUI file. For example: 26 26 27 || '''Original''' || XML file:[[BR]]`<action on="Load"> 28 || '''Wrong''' || XML file:[[BR]]`<action on="Load"> 29 || '''Internationalized''' || XML file:[[BR]]`<action on="Load"> this.caption = getBuildTimeString()</action>`[[BR]][[BR]]!JavaScript file included by the GUI file:[[BR]]`function getBuildTimeString(){return sprintf(translate("Build: %(buildTime)s"), { buildTime: Engine.!GetBuildTime() });}` ||27 || '''Original''' || XML file:[[BR]]`<action on="Load"> this.caption = "Build:" + ``Engine.GetBuildTime();</action>` || 28 || '''Wrong''' || XML file:[[BR]]`<action on="Load"> this.caption = sprintf(translate("Build: %(buildTime)s"), { buildTime: Engine.GetBuildTime() });</action>` || 29 || '''Internationalized''' || XML file:[[BR]]`<action on="Load"> this.caption = getBuildTimeString()</action>`[[BR]][[BR]]!JavaScript file included by the GUI file:[[BR]]`function getBuildTimeString(){ return sprintf(translate("Build: %(buildTime)s"), { buildTime: Engine.!GetBuildTime() });}` || 30 30 31 31 = Internationalizing !JavaScript Files =