====== gettext.js ======
Localized/customized support for JavaScript user-visible text (i.e. strings not contained in text.dat)

===== Usage =====
Customized text strings go in the ''[scriptfilename.js]'' or ''[JS]'' sections of ''[[dir:ctrl]]/[[custom:text.ini]]''. If a text key exists in the ''[scriptfilename.js]'' section, it will take precedence over the same key existing in the ''[JS]'' section.

Localized (translated to non-default locale) text strings go in the equivalent sections of ''[[dir:ctrl]]/text.<lang>.ini''

By ''load()''ing or ''require()''ing ''gettext.js'', a JavaScript module can gain localization/customization support by simply wrapping strings (words, terms) in calls to ''gettext()''. For example:

<code JavaScript>
load("gettext.js");
print(gettext("This string is now localizable."));
</code>

Then in their ''[[dir:ctrl]]/text.ini'' file, a sysop can easily override that string:

<file ini>
[JS]
This string is now localizable. = This is my custom string replacement.
</file>

For easier localization, it's recommended that Ctrl-A codes/sequences are contained in separate strings from words/terms that can be translated for other locales.

To expose strings that contain Ctrl-A (or control characters) for localization/customization via ''text.ini'', specify a simple ASCII //key//:

<code JavaScript>
print(gettext("This string with \x01hbright text\x01n is now localizable.", "localizable_example"));
</code>

Then in their ''[[dir:ctrl]]/text.ini'' file, a sysop can easily override that string((notice the use of string literal syntax instead of the more typical key = value syntax)):

<file ini>
[JS]
localizable_example: "My new string with \x01bright text\x01n is here."
</file>

===== See Also =====
  * [[:custom:javascript:lib:|custom:javascript:lib index]]

{{tag>localization}}
