Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.0.0 - Русский


tbx_generate_pofile

Extracts gettext msgid strings from the toolbox source files. Creates/updates .po files

Syntax

pofile = tbx_generate_pofile()
pofile = tbx_generate_pofile(tbx_path)
pofile = tbx_generate_pofile(tbx_name)             // obsolete
pofile = tbx_generate_pofile(tbx_name, tbx_path)   // obsolete

Arguments

tbx_path

path of the toolbox, use to locate files to compile.

tbx_name (obsolete)

name of the toolbox, use to name localization files and domain.

tbx_name is now retrieved as the basename of the file tbx_path/etc/*.start. This file must exist, even if it is empty.
pofile

return the generated po file path.

Description

tbx_generate_pofile(…) scans all toolbox source files for every call to gettext(domain,msgid), _(domain,msgid), (or _d(domain,msgid) in XML files like the preferences file, if any). Then, ~ being the toolbox root directory:

  • If the ~/locales/en_US.po reference file does not exist yet, it is created.

  • Otherwise, all existing ~/locales/*.po files are updated with gettext msgid strings newly detected in all source files of the toolbox. Note: presently, obsolete msgids (no longer present in any source file) are kept.

For each processed .po file (but en_US.po), the number of messages whose translation is still missing is displayed.

Translators are expected to edit ~/locales/*.po files for their language, and write in msgstr strings the translation of the related msgid given in english as appearing as gettext() argument in source files. Here is a sample of a fr_FR.po file:

#: ~\macros\scilab_add.sci:13       << file:line_number places where gettext() is called for the msgid.
#: ~\macros\scilab_error.sci:22     << The same message is used in another file. etc.
msgid "New message #2.\n"           << gettext() argument = reference message (english)
msgstr "Nouveau message n° 2.\n"    << translated message (entered by a translator).

#: ~\macros\scilab_add.sci:16
msgid "New message #3.\n"
msgstr ""                            << Missing translation, to complete.

Examples

path = TMPDIR + "/example";
copyfile(SCI+"/contrib/toolbox_skeleton", path);
mdelete(path+"/locales/*");

tbx_generate_pofile(path);
edit(path+"/locales/en_US.po")

See also

  • gettext — индексирует или/и переводит некоторые индексированные сообщения на английском языке
  • addlocalizationdomain — add a new domain in localization mechanism.
  • tbx_make . localization — Builds fully or some given sections of a toolbox having a standard structure
  • tbx_build_localization — Builds or updates localization .po and .mo files of a toolbox

History

ВерсияОписание
5.5.0 Function tbx_generate_pofile added.
6.0.0 tbx_name declared obsolete. It is no longer required.
6.0.1
  • _() and gettext() references are now detected.
  • Literal double '' are now simplified in the msgid.
  • Files paths in comments are no longer absolute and refer to the toolbox root.
6.1.2 Existing .po files are now automatically updated for every newly detected msgid.
Report an issue
<< tbx_builder_src_lang Helper functions tbx_make >>

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:
Tue Oct 24 14:37:13 CEST 2023