Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.1.0 - 日本語


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 running tbx_make(…,"localization") or tbx_build_localization(…), the domain 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, and SCIHOME, that are automatically expanded.

When this directory has been created when running tbx_make(…, "localization") or tbx_build_localization(…), this toolbox subdirectory is named locales 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

バージョン記述
5.5.0 addlocalizationdomain function added.
Report an issue
<< Localization Localization getdefaultlanguage >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon May 22 12:43:16 CEST 2023