308
edits
Line 99: | Line 99: | ||
== Formatting templates == | == Formatting templates == | ||
Localizable strings will often contain variable references and other code in {curly braces}, following the [http://code.google.com/p/trimpath/wiki/JavaScriptTemplates JavaScript Templates] format. For example, you may see a string like this: | |||
msgid "${number} results found." | |||
In these cases, the <code>${number}</code> is going to be replaced out by some data, so you will want to leave it alone in your localization, for example (French): | |||
msgstr "Il y a ${number} résultats." | |||
JavaScript templates can also include some basic control structures, most importantly letting you handle pluralization directly in the . Suppose you want your localized string to display slightly differently depending on whether the <code>number</code> value is singular or plural. The JavaScript Templates format allows for a simple <code>{if}</code> statement to handle these possibilities: | |||
msgstr "Il y a ${number} résultat{if number > 1}s{/if}." | |||
This string will produce "Il y a 3 résultat'''s'''." when plural and "Il y a 1 résultat." when singular as we would like. You can also write an <code>{else}</code> condition, using the pattern | |||
{if ...} ... {else} ... {/if} | |||
Alternatively, suppose the source language includes such special syntax for pluralization, but your language does not have plural marking. You can simply remove the <code>{if}...</code> control structure from the localized string. | |||
msgid "${number} result{if number > 1}s{/if} found." | |||
msgstr "找到${number}個結果" | |||
== Contributing your localizations == | |||
Currently the latest versions of Ubiquity built-in command localizations are kept in Ubiquity's main [https://ubiquity.mozilla.com/hg/ubiquity-firefox/ hg repository]. You can sumbit new localizations by posting them on [https://ubiquity.mozilla.com/trac/ticket/712 this trac ticket]. | |||
You can also ask questions and seek help on Ubiquity localization on the [http://groups.google.com/group/ubiquity-i18n The Ubiquity i18n Google Group]. | |||
== References == | |||
* [[Labs/Ubiquity/i18n]], the Ubiquity i18n project wiki page | |||
* [http://groups.google.com/group/ubiquity-i18n The Ubiquity i18n Google Group], a mailing list to discuss Ubiquity internationalization and localization | |||
* [[Labs/Ubiquity/Ubiquity_0.5_Making_Commands_Localizable|Making commands localizable]], a guide for command authors | |||
* [[Labs/Ubiquity/Parser_2/Localization_Tutorial|Parser 2 localization tutorial]], how to actually teach Ubiquity the grammar of your language | |||
* [http://www.gnu.org/software/gettext/manual/gettext.html The GNU gettext manual] | |||
* [http://jsgettext.berlios.de/ JS Gettext], the open source JavaScript library chosen to incorporate <code>po</code> file handling in Ubiquity. |
edits