Changes between Version 7 and Version 8 of Internationalization
- Timestamp:
- Apr 13, 2014, 2:05:13 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Internationalization
v7 v8 106 106 Plural functions require that you pass them two versions of the same message: a message in singular form (`number = 1`) and a message in plural form (`number != 1`). This is because those are the English plural forms. However, other languages may have more plural forms or no plural forms at all. That is why you must specify an integer, `number`, that is the number of items represented in your message. 107 107 108 TODO: several plurals in one sentence (use string formatting) 109 108 110 === Using Context Functions === 109 111 Context functions are used to handle cases where an English string may have a different meaning depending on the context. When that happens, chances are other languages use different words for each one of those meanings. If you use a context-free internationalization function (`translate` or `translatePlural`) to translate two messages that contain the same text, when you generate a translation template (POT file) from the sources, both messages are treated as a single message, and translators can only translate the message one way or another. If instead you use a context function (`translateWithContext` or `translatePluralWithContext`) and specify a different context for each message, translators will be able to translate each message differently. … … 120 122 121 123 * '''Single words'''. When you translate a single word, you are likely to need a context. 122 * '''Unclear verb tenses ''' '''or nouns'''. More often than not, the same English word may represent two or more different tenses of a verb, and also work as a noun or other type of word. If the message string is not clear enough as to which of those tenses is being used or whether the word is working as a verb or as a different type of word, you need a context.124 * '''Unclear verb tenses or nouns'''. More often than not, the same English word may represent two or more different tenses of a verb, and also work as a noun or other type of word. If the message string is not clear enough as to which of those tenses is being used or whether the word is working as a verb or as a different type of word, you need a context. 123 125 124 126 === Using Format Strings Instead of Concatenating Strings in !JavaScript === 125 TODO: sprintf. 127 128 You should '''never''' concatenate translatable strings, as the position of each member of the concatenation may change in other languages. Instead, use the `sprintf` global function for string formatting: 129 130 '''Original:''' 131 132 {{{ 133 fpsCaption = "FPS: " + Engine.GetFPS(); 134 progressCaption = "Uploading… (" + Math.floor(100*done) + "%)"; 135 }}} 136 137 '''Internationalized:''' 138 139 {{{ 140 fpsCaption = sprintf(translate("FPS: %(fps)s"), { fps: Engine.GetFPS() }); 141 progressCaption = sprintf(translate("Uploading… (%f%%)"), Math.floor(100*done)); 142 }}} 126 143 127 144 = Internationalizing Data Files =