From: Bruno Haible Date: Tue, 27 Nov 2001 13:05:19 +0000 (+0000) Subject: New option --no-translator. X-Git-Tag: v0.11~265 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=329e789b2f14a12647f388d9cc6ba326f0c085a0;p=thirdparty%2Fgettext.git New option --no-translator. --- diff --git a/doc/ChangeLog b/doc/ChangeLog index ceefdf0d1..b1e640357 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2001-11-25 Bruno Haible + + * msginit.texi: Document option --no-translator. + 2001-11-18 Karl Eichwalder * gettext.texi (Main PO Commands, Entry Positioning, Marking, diff --git a/doc/msginit.texi b/doc/msginit.texi index 2038a5862..c83ff94f7 100644 --- a/doc/msginit.texi +++ b/doc/msginit.texi @@ -39,6 +39,10 @@ Set target locale. @var{ll} should be a language code, and @var{CC} should be a country code. The command @samp{locale -a} can be used to output a list of all installed locales. The default is the user's locale setting. +@item --no-translator +Declares that the PO file will not have a human translator and is instead +automatically generated. + @item -w @var{number} @itemx --width=@var{number} Set the output page width. Long strings in the output files will be diff --git a/src/ChangeLog b/src/ChangeLog index 13f162114..67e3634f9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2001-11-25 Bruno Haible + + * msginit.c (no_translator): New variable. + (long_options): Add option --no-translator. + (main): Handle option --no-translator. + (usage): Document option --no-translator. + (po_revision_date): Add header argument. Return POT's creation date + if no_translator. + (last_translator): Return a dummy string if no_translator. + (language_team): Likewise. + (fields): Allow getter with 0 or 1 argument. + (get_field): New function. + (fill_header): Call getter with 0 or 1 argument. + 2001-11-25 Bruno Haible * msginit.c (canonical_locale_charset): Return the charset of 'locale' diff --git a/src/msginit.c b/src/msginit.c index 60336a449..2cdee8c6c 100644 --- a/src/msginit.c +++ b/src/msginit.c @@ -102,12 +102,16 @@ static const char *catalogname; /* Language (ISO-639 code). */ static const char *language; +/* If true, the user is not considered to be the translator. */ +static bool no_translator; + /* Long options. */ static const struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "input", required_argument, NULL, 'i' }, { "locale", required_argument, NULL, 'l' }, + { "no-translator", no_argument, NULL, CHAR_MAX + 1 }, { "output-file", required_argument, NULL, 'o' }, { "version", no_argument, NULL, 'V' }, { "width", required_argument, NULL, 'w' }, @@ -128,7 +132,7 @@ static const char *canonical_locale_charset PARAMS ((void)); static const char *englishname_of_language PARAMS ((void)); static const char *project_id PARAMS ((void)); static const char *project_id_version PARAMS ((void)); -static const char *po_revision_date PARAMS ((void)); +static const char *po_revision_date PARAMS ((const char *header)); static struct passwd *get_user_pwd PARAMS ((void)); static const char *get_user_fullname PARAMS ((void)); static const char *get_user_email PARAMS ((void)); @@ -139,9 +143,7 @@ static const char *mime_version PARAMS ((void)); static const char *content_type PARAMS ((void)); static const char *content_transfer_encoding PARAMS ((void)); static const char *plural_forms PARAMS ((void)); -#ifdef unused static char *get_field PARAMS ((const char *header, const char *field)); -#endif static char *put_field PARAMS ((const char *old_header, const char *field, const char *value)); static const char *get_title PARAMS ((void)); @@ -228,6 +230,10 @@ main (argc, argv) } break; + case CHAR_MAX + 1: + no_translator = true; + break; + default: usage (EXIT_FAILURE); break; @@ -369,6 +375,7 @@ locale setting. If it is -, the results are written to standard output.\n\ printf (_("\ Output details:\n\ -l, --locale=LL_CC set target locale\n\ + --no-translator assume the PO file is automatically generated\n\ -w, --width=NUMBER set output page width\n\ ")); printf ("\n"); @@ -945,12 +952,21 @@ project_id_version () /* Construct the value for the PO-Revision-Date field. */ static const char * -po_revision_date () +po_revision_date (header) + const char *header; { - time_t now; + if (no_translator) + /* Because the PO file is automatically generated, we use the + POT-Creation-Date, not the current time. */ + return get_field (header, "POT-Creation-Date"); + else + { + /* Assume the translator will modify the PO file now. */ + time_t now; - time (&now); - return po_strftime (&now); + time (&now); + return po_strftime (&now); + } } @@ -1076,13 +1092,18 @@ you in case of unexpected technical problems.\n"); static const char * last_translator () { - const char *fullname = get_user_fullname (); - const char *email = get_user_email (); - - if (fullname != NULL) - return xasprintf ("%s <%s>", fullname, email); + if (no_translator) + return "Automatically generated"; else - return xasprintf ("<%s>", email); + { + const char *fullname = get_user_fullname (); + const char *email = get_user_email (); + + if (fullname != NULL) + return xasprintf ("%s <%s>", fullname, email); + else + return xasprintf ("<%s>", email); + } } @@ -1138,13 +1159,18 @@ language_team_address () static const char * language_team () { - const char *englishname = englishname_of_language (); - const char *address = language_team_address (); - - if (address != NULL && address[0] != '\0') - return xasprintf ("%s %s", englishname, address); + if (no_translator) + return "none"; else - return englishname; + { + const char *englishname = englishname_of_language (); + const char *address = language_team_address (); + + if (address != NULL && address[0] != '\0') + return xasprintf ("%s %s", englishname, address); + else + return englishname; + } } @@ -1228,24 +1254,28 @@ plural_forms () } -static struct { const char *name; const char * (*getter) PARAMS ((void)); } +static struct +{ + const char *name; + const char * (*getter0) PARAMS ((void)); + const char * (*getter1) PARAMS ((const char *header)); +} fields[] = { - { "Project-Id-Version", project_id_version }, - { "PO-Revision-Date", po_revision_date }, - { "Last-Translator", last_translator }, - { "Language-Team", language_team }, - { "MIME-Version", mime_version }, - { "Content-Type", content_type }, - { "Content-Transfer-Encoding", content_transfer_encoding }, - { "Plural-Forms", plural_forms } + { "Project-Id-Version", project_id_version, NULL }, + { "PO-Revision-Date", NULL, po_revision_date }, + { "Last-Translator", last_translator, NULL }, + { "Language-Team", language_team, NULL }, + { "MIME-Version", mime_version, NULL }, + { "Content-Type", content_type, NULL }, + { "Content-Transfer-Encoding", content_transfer_encoding, NULL }, + { "Plural-Forms", plural_forms, NULL } }; #define NFIELDS SIZEOF (fields) #define FIELD_LAST_TRANSLATOR 2 -#ifdef unused /* Retrieve a freshly allocated copy of a field's value. */ static char * get_field (header, field) @@ -1285,7 +1315,6 @@ get_field (header, field) return NULL; } -#endif /* Add a field with value to a header, and return the new header. */ static char * @@ -1560,7 +1589,10 @@ fill_header (mdlp) for (i = 0; i < NFIELDS; i++) { if (field_value[i] == NULL) - field_value[i] = fields[i].getter (); + field_value[i] = + (fields[i].getter1 != NULL + ? fields[i].getter1 (header) + : fields[i].getter0 ()); if (field_value[i] != NULL) {