]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Add --its option for ease of testing
authorDaiki Ueno <ueno@gnu.org>
Thu, 10 Dec 2015 03:10:44 +0000 (12:10 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 10 Dec 2015 03:11:58 +0000 (12:11 +0900)
* 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
gettext-tools/src/xgettext.c

index 1a1bbc7b0fcb9dc09cd1c10b68f31172d056c98d..d6a5f019f2bfc1e193fb5db7d8a6601f86c4ca34 100644 (file)
@@ -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}).
index 08cb179cd0629c2f183965d11ff04f067751c83d..314d35c349dc766545059a674d2e114f1a359643 100644 (file)
@@ -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"));