--extract-all
with の使用xgettext
は、複数形では機能しません。I18n C++ hello worldへの回答を複数形で C++ コードとして使用すると、xgettext
.
cat >helloplurals.cxx <<EOF
// hellopurals.cxx
#include <libintl.h>
#include <locale.h>
#include <iostream>
int main (){
setlocale(LC_ALL, "");
bindtextdomain("helloplurals", ".");
textdomain( "helloplurals");
for (int ii=0; ii<5; ii++)
printf(ngettext("Hello world with %d moon.\n", "Hello world with %d moons.\n", ii), ii);
EOF
xgettext --package-name helloplurals --package-version 1.1 --default-domain helloplurals --output helloplurals.pot helloplurals.cxx
xgettext --extract-all --package-name helloplurals --package-version 1.1 --default-domain helloplurals --output helloplurals-ea.pot helloplurals.cxx
--extract-all
複数形の処理を含め、期待どおりに動作しないもの:
#: helloplurals.cxx:10
#, c-format
msgid "Hello world with %d moon.\n"
msgid_plural "Hello world with %d moons.\n"
msgstr[0] ""
msgstr[1] ""
をコマンド ラインに追加する--extract-all
と、結果の POT ファイルは追加されません。代わりに、別のエントリがあります。
#: helloplurals.cxx:10
#, c-format
msgid "Hello world with %d moon.\n"
msgstr ""
#: helloplurals.cxx:10
#, c-format
msgid "Hello world with %d moons.\n"
msgstr ""
の最初の使用例で示したように、like 関数に直接渡される文字列リテラルは、gettext()
複数のメッセージを適切に処理しますxgettext
。
同様の関数のいずれかに直接渡されない文字列リテラルの場合、 withgettext()
オプションを使用して、POT ファイルにエントリを生成できます。--extract-all
xgettext
複数のエントリを生成するために like 関数に 直接gettext()
渡される複数の文字列リテラルも含むソース内の like 関数に直接渡されない文字列リテラルの処理をどのように取得しますか?gettext()
msgid_plural
msgstr[]