summaryrefslogtreecommitdiff
path: root/locale/po2strings.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2009-02-04 04:27:58 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2009-02-04 04:27:58 +0000
commit745129beebf8651dd9ce221cc7c046460b4ae8f6 (patch)
tree36a3744f51208f5de35489ce45064f90499a450e /locale/po2strings.c
parentdfd5680b8770f4dd462a90a7a6579aa9523e484f (diff)
Merge changes from CUPS 1.4svn-r8329.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1182 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'locale/po2strings.c')
-rw-r--r--locale/po2strings.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/locale/po2strings.c b/locale/po2strings.c
index 8699687f0..1f4aa9f0a 100644
--- a/locale/po2strings.c
+++ b/locale/po2strings.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <cups/i18n.h>
+#include <cups/string.h>
/*
@@ -47,15 +48,42 @@ int /* O - Exit code */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
+ int i; /* Looping var */
FILE *strings; /* .strings file */
cups_array_t *po; /* .po file */
char iconv[1024]; /* iconv command */
_cups_message_t *msg; /* Current message */
+ const char *srcfile, /* Source file */
+ *dstfile; /* Destination file */
+ int use_msgid; /* Use msgid strings for msgstr? */
- if (argc != 3)
+ srcfile = NULL;
+ dstfile = NULL;
+ use_msgid = 0;
+
+
+ for (i = 1; i < argc; i ++)
+ if (!strcmp(argv[i], "-m"))
+ use_msgid = 1;
+ else if (argv[i][0] == '-')
+ {
+ puts("Usage: po2strings [-m] filename.po filename.strings");
+ return (1);
+ }
+ else if (srcfile == NULL)
+ srcfile = argv[i];
+ else if (dstfile == NULL)
+ dstfile = argv[i];
+ else
+ {
+ puts("Usage: po2strings [-m] filename.po filename.strings");
+ return (1);
+ }
+
+ if (!srcfile || !dstfile)
{
- puts("Usage: po2strings filename.po filename.strings");
+ puts("Usage: po2strings [-m] filename.po filename.strings");
return (1);
}
@@ -63,9 +91,9 @@ main(int argc, /* I - Number of command-line args */
* Use the CUPS .po loader to get the message strings...
*/
- if ((po = _cupsMessageLoad(argv[1])) == NULL)
+ if ((po = _cupsMessageLoad(srcfile)) == NULL)
{
- perror(argv[1]);
+ perror(srcfile);
return (1);
}
@@ -74,7 +102,7 @@ main(int argc, /* I - Number of command-line args */
* The .po file uses UTF-8...
*/
- snprintf(iconv, sizeof(iconv), "iconv -f utf-8 -t utf-16 >'%s'", argv[2]);
+ snprintf(iconv, sizeof(iconv), "iconv -f utf-8 -t utf-16 >'%s'", dstfile);
if ((strings = popen(iconv, "w")) == NULL)
{
perror(argv[2]);
@@ -88,7 +116,7 @@ main(int argc, /* I - Number of command-line args */
{
write_string(strings, msg->id);
fputs(" = ", strings);
- write_string(strings, msg->str);
+ write_string(strings, use_msgid ? msg->id : msg->str);
fputs(";\n", strings);
}