From 30d474e1cedc14611a725f1824c55dd6cc6f42b2 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Thu, 10 Dec 2015 12:10:44 +0900 Subject: xgettext: Add --its option for ease of testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- gettext-tools/doc/xgettext.texi | 5 +++++ gettext-tools/src/xgettext.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/gettext-tools/doc/xgettext.texi b/gettext-tools/doc/xgettext.texi index 1a1bbc7b0..d6a5f019f 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 08cb179cd..314d35c34 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")); -- cgit v1.2.1