addlocalizationdomain
add a new domain in localization mechanism.
Syntax
msg = addlocalizationdomain(domain, path)
Arguments
- domain
a string: The name of the messages domain. That's the string used as first argument when calling
gettext(domain, msgid)
in the code of the toolbox.Setting
domain
to the toolbox name will be most often relevant. Indeed, when runningtbx_make(…,"localization")
ortbx_build_localization(…)
, thedomain
used by default to build translation files is the toolbox name (that is the base name * of the ./etc/*.start file of the toolbox).- path
Absolute path to the toolbox subdirectory containing the languages subdirectories and translated .po and .mo files. It can start with
SCI
,WSCI
,TMPDIR
, andSCIHOME
, that are automatically expanded.When this directory has been created when running
tbx_make(…, "localization")
ortbx_build_localization(…)
, this toolbox subdirectory is namedlocales
by default.
Examples
old = getlanguage(); setlanguage("fr_FR"); msgid = "%s: something not in Scilab.\n"; // This message has no translation in Scilab, noticeably to french. // So trying to translate it "in the main Scilab domain" fails: The msgid is returned as is: gettext(msgid) _(msgid) // But it has been translated for tests, under the "tbx" domain, and translated files // are stored in SCI/modules/localization/tests/unit_tests/locale subdirectories addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale") gettext("tbx", msgid) _("tbx", msgid) // The gettext("tbx",..) call indexing this msgid is in edit SCI/modules/localization/tests/unit_tests/addlocalizationdomain.tst // Its (wrong) translation to french is stored in edit SCI/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.po setlanguages(old);
--> msgid = "%s: something not in Scilab.\n"; --> --> // This message has no translation in Scilab, noticeably to french. --> // So trying to translate it "in the Scilab domain" fails: The msgid is returned as is: --> gettext(msgid) ans = "%s: something not in Scilab.\n" --> _(msgid) ans = "%s: something not in Scilab.\n" --> // But it has been translated for tests, under the "tbx" domain, and translated files --> // are stored in SCI/modules/localization/tests/unit_tests/locale subdirectories --> addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale") ans = T --> gettext("tbx", msgid) ans = "%s : it is true, that is not in Scilab.\n" --> _("tbx", msgid) ans = "%s : it is true, that is not in Scilab.\n"
See also
- gettext — indexes or/and translates some indexed english messages
- tbx_generate_pofile — Extracts gettext msgid strings from the toolbox source files. Creates/updates .po files
History
Version | Description |
5.5.0 | addlocalizationdomain function added. |
Report an issue | ||
<< Localização | Localização | getdefaultlanguage >> |