summaryrefslogtreecommitdiffstats
path: root/gettext-tools
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2015-12-10 12:10:44 +0900
committerDaiki Ueno <ueno@gnu.org>2015-12-10 12:11:58 +0900
commit30d474e1cedc14611a725f1824c55dd6cc6f42b2 (patch)
treeeb972284a1ac3ed92aa51bc2e1dd9b2d44443ace /gettext-tools
parentfe3fee6f1fd6a196b3dcc6937fc41a295a287319 (diff)
downloadexternal_gettext-30d474e1cedc14611a725f1824c55dd6cc6f42b2.zip
external_gettext-30d474e1cedc14611a725f1824c55dd6cc6f42b2.tar.gz
external_gettext-30d474e1cedc14611a725f1824c55dd6cc6f42b2.tar.bz2
xgettext: Add --its option for ease of testing
* gettext-tools/doc/xgettext.texi (Output details): Mention --its option. * gettext-tools/src/xgettext.c (long_options): Add --its option. (main): Handle --its option. Suggested by Sébastien Wilmet.
Diffstat (limited to 'gettext-tools')
-rw-r--r--gettext-tools/doc/xgettext.texi5
-rw-r--r--gettext-tools/src/xgettext.c24
2 files changed, 29 insertions, 0 deletions
diff --git a/gettext-tools/doc/xgettext.texi b/gettext-tools/doc/xgettext.texi
index 1a1bbc7..d6a5f01 100644
--- a/gettext-tools/doc/xgettext.texi
+++ b/gettext-tools/doc/xgettext.texi
@@ -500,6 +500,11 @@ obsolete messages.
Write out a NeXTstep/GNUstep localized resource file in @code{.strings} syntax.
Note that this file format doesn't support plural forms.
+@item --its=@var{file}
+@opindex --its@r{, @code{xgettext} option}
+Use ITS rules defined in @var{file}.
+Note that this is only effective with XML files.
+
@item --itstool
@opindex --itstool@r{, @code{xgettext} option}
Write out comments recognized by itstool (@uref{http://itstool.org}).
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index 08cb179..314d35c 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -246,6 +246,7 @@ static const struct option long_options[] =
{ "from-code", required_argument, NULL, CHAR_MAX + 3 },
{ "help", no_argument, NULL, 'h' },
{ "indent", no_argument, NULL, 'i' },
+ { "its", required_argument, NULL, CHAR_MAX + 20 },
{ "itstool", no_argument, NULL, CHAR_MAX + 19 },
{ "join-existing", no_argument, NULL, 'j' },
{ "kde", no_argument, NULL, CHAR_MAX + 10 },
@@ -329,6 +330,7 @@ main (int argc, char *argv[])
bool sort_by_msgid = false;
bool sort_by_filepos = false;
char *its_dirs[2] = { NULL, NULL };
+ char *explicit_its_filename = NULL;
const char *file_name;
const char *files_from = NULL;
string_list_ty *file_list;
@@ -655,6 +657,10 @@ main (int argc, char *argv[])
error (EXIT_FAILURE, 0, _("sentence end type '%s' unknown"), optarg);
break;
+ case CHAR_MAX + 20: /* --its */
+ explicit_its_filename = optarg;
+ break;
+
case CHAR_MAX + 19: /* --itstool */
add_itstool_comments = true;
break;
@@ -743,6 +749,12 @@ xgettext cannot work without keywords to look for"));
locating_rule_list_add_from_directory (its_locating_rules, its_dirs[i]);
}
+ /* Explicit ITS file selection and language specification are
+ mutually exclusive. */
+ if (explicit_its_filename != NULL && language != NULL)
+ error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"),
+ "--its", "--language");
+
/* Determine extractor from language. */
if (language != NULL)
extractor = language_to_extractor (language);
@@ -847,6 +859,16 @@ This version was built without iconv()."),
if (extractor.func)
this_file_extractor = extractor;
+ else if (explicit_its_filename != NULL)
+ {
+ its_rules = its_rule_list_alloc ();
+ if (!its_rule_list_add_from_file (its_rules,
+ explicit_its_filename))
+ {
+ error (EXIT_FAILURE, 0, _("\
+warning: ITS rule file '%s' does not exist"), explicit_its_filename);
+ }
+ }
else
{
const char *language_from_extension = NULL;
@@ -1172,6 +1194,8 @@ Output details:\n"));
printf (_("\
--stringtable-output write out a NeXTstep/GNUstep .strings file\n"));
printf (_("\
+ --its=FILE apply ITS rules from FILE\n"));
+ printf (_("\
--itstool write out itstool comments\n"));
printf (_("\
-w, --width=NUMBER set output page width\n"));