gettext text tries to return the translation of the text string into the user's preferred language, in the current context. This will load the corresponding "locales" files, when available. If the translation is not found, other contexts will be examined. If everything fails, the original text string is returned.
val gettext_opt : string ->string option
Similar to gettext but returns None if the translation cannot be found.
let translated = tt "Hello" in
for _ = 1 to 10 do print_endline (tf translated)
tf means "translation force"
Translating printf formats
Sometimes the translation of a format string like "%u dollars off coupon" imposes to change the location of the special flags, as in "bon de réduction de %u dollars".
Therefore it's easier to translate the whole format string instead of working word by word. The I18n module provides facilities for this.
val t_uint2 : string ->(int ->int -> string)Lazy.t
Similar to t_uint but the format string should contain two %s flags.
Declaring new translations
Translations can be added either programmatically using add_translation or by directly editing the configurations files.
val add_translation : locale->string ->string -> unit
add_translation locale text translation will declare the string translation to be the translation of the string text within the current context and for the given locale. This will overwrite previously defined translations for text.
This function does not modifies the translation files. See save_locale.