-
Notifications
You must be signed in to change notification settings - Fork 347
Internationalization and Localization
OGS is available in 32 languages and counting. This is an effort that is supported by both developers and translators.
Any time you display a string in the UI, it should be wrapped in one of the functions from translate.ts. These functions replicate the API of GNU gettext.
The simplest function in translate.ts is gettext(msgid:string)
, but it is often used under the alias _
for brevity. At runtime, this function translates an English string to the user's language.
_("New to Go? Click here to learn how to play!")
Occasionally, the English is not enough to determine a translation. For instance, the word "Move" can be both a noun and a verb in English. So you can provide context with the pgettext(context:string, msgid:string)
function:
pgettext("Game list move number", "Move")
Another case that needs to be handled is plurals. In this case, we use ngettext(singular:string, plural:string, count:number)
:
ngettext("capture", "captures", num_prisoners)
npgettext(context, singular, plural, count)
specifies both context and plurality.
TODO: potentially describe the following. Alternatively, document the source directly and just point the user there
get_format
interpolate
cc_to_country_name
current_language
languages
countries
getCountryFlagClass
getLanguageFlag
TODO: Add info on the translation aspect
https://translate.online-go.com https://github.com/online-go/online-go.com/tree/devel/i18n