I have some misunderstanding of how xgettext tool parses C source files and gathers strings for further translation.
I use xgettext tool version 0.10.35 and it turned out that it does not recognize strings defined like macroses during parsing.
For example we have test_xgettext.c file with next content:
#include <stdio.h>
#define _(str) str
#define STRING_1 _("string 1")
int main(void)
{
printf(STRING_1);
printf(_("string 2"));
return 0;
}
If we run
xgettext.exe test_xgettext.c -o test_xgettext.pot -k_
we will have test_xgettext.pot file with next content:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2016-09-01 12:39+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
#: test_xgettext.c:10
msgid "string 2"
msgstr ""
Here we only have "string 2" in POT file, and my goal is to gather both "string 1" and "string 2".
Thank you in advance for help.
It turned out that it works for xgettext 0.10.35 if we use array instead of macro.
Modified source file:
#include <stdio.h>
#define _(str) str
char STRING_1[] = _("string 1");
int main(void)
{
printf(STRING_1);
printf(_("string 2"));
return 0;
}
In this case we have next output in POT file (I left out not important lines):
#: test_xgettext.c:5
msgid "string 1"
msgstr ""
#: test_xgettext.c:10
msgid "string 2"
msgstr ""
It also turned out that it works as it was initially expected with xgettext version 0.19.8.1 (Windows 7 Professional). Source file:
#include <stdio.h>
#define _(str) str
#define STRING_1 _("string 1")
int main(void)
{
printf(STRING_1);
printf(_("string 2"));
return 0;
}
Generated POT file:
#: test_xgettext.c:5
msgid "string 1"
msgstr ""
#: test_xgettext.c:10
#, c-format
msgid "string 2"
msgstr ""