Now that Git has the infrastructure for translation in next I'm going
to start submitting patches to make the main porcelain translatable.
This series starts that work, and fixes and also fixes up some of the
infrastructure (like the bug discussed in "Odd encoding issue with
UTF-8 + gettext yields ? on non-ASCII"), and adds tests to make sure
it's all working.
With it applied git-init is the one and only utility of the porcelain
that's translatable. The series includes a translation of it into
Icelandic and Polish.
I think it's ready to be applied. I tested it on Solaris, FreeBSD and
Debian. But there's almost definitely something I'm missing in a
series this big, so it's an RFC.
Marcin Cieślak (1):
po/pl.po: add Polish translation
Ævar Arnfjörð Bjarmason (16):
Makefile: A variable for options used by xgettext(1) calls
Makefile: provide a --msgid-bugs-address to xgettext(1)
Makefile: tell xgettext(1) that our source is in UTF-8
builtin.h: Include gettext.h
gettext: make the simple parts of git-init localizable
gettext: localize the main git-init message
gettext.c: work around us not using setlocale(LC_CTYPE, "")
gettext tests: test if $VERSION exists before using it
gettext tests: update test/is.po to match t/t0200/test.c
gettext tests: add detection for is_IS.ISO-8859-1 locale
gettext tests: test message re-encoding under Shell
gettext tests: test re-encoding with a UTF-8 msgid under Shell
gettext tests: mark a test message as not needing translation
po/is.po: msgmerge and add Language: header
po/is.po: add Icelandic translation
gettext tests: test message re-encoding under C
Makefile | 7 +-
builtin.h | 1 +
builtin/init-db.c | 56 ++++++-----
gettext.c | 6 +
po/is.po | 153 ++++++++++++++++++++++++++++--
po/pl.po | 187 ++++++++++++++++++++++++++++++++++++
t/lib-gettext.sh | 26 +++++-
t/t0200-gettext-basic.sh | 4 +-
t/t0200/test.c | 10 ++
t/t0202/test.pl | 4 +-
t/t0204-gettext-reencode-sanity.sh | 78 +++++++++++++++
11 files changed, 490 insertions(+), 42 deletions(-)
create mode 100644 po/pl.po
create mode 100755 t/t0204-gettext-reencode-sanity.sh
--
1.7.2.2.536.g3f548
Change the user visible strings in init-db.c to use gettext
localizations. This only converts messages which needed to be changed
from "foo" to _("foo"), and didn't need any TRANSLATORS comments.
I haven't marked the messages in init_db_usage or init_db_options for
translation, since that would require additional changes in
parse-options.c. Those can be done later.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
builtin/init-db.c | 46 +++++++++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)}}elseif(share&&adjust_shared_perm(dir))-die("Could not make %s writable by group",dir);+die(_("Could not make %s writable by group"),dir);}staticvoidcopy_templates_1(char*path,intbaselen,
@@ -58,25 +58,25 @@ static void copy_templates_1(char *path, int baselen,namelen=strlen(de->d_name);if((PATH_MAX<=baselen+namelen)||(PATH_MAX<=template_baselen+namelen))-die("insanely long template name %s",de->d_name);+die(_("insanely long template name %s"),de->d_name);memcpy(path+baselen,de->d_name,namelen+1);memcpy(template+template_baselen,de->d_name,namelen+1);if(lstat(path,&st_git)){if(errno!=ENOENT)-die_errno("cannot stat '%s'",path);+die_errno(_("cannot stat '%s'"),path);}elseexists=1;if(lstat(template,&st_template))-die_errno("cannot stat template '%s'",template);+die_errno(_("cannot stat template '%s'"),template);if(S_ISDIR(st_template.st_mode)){DIR*subdir=opendir(template);intbaselen_sub=baselen+namelen;inttemplate_baselen_sub=template_baselen+namelen;if(!subdir)-die_errno("cannot opendir '%s'",template);+die_errno(_("cannot opendir '%s'"),template);path[baselen_sub++]=template[template_baselen_sub++]='/';path[baselen_sub]=
@@ -93,20 +93,20 @@ static void copy_templates_1(char *path, int baselen,intlen;len=readlink(template,lnk,sizeof(lnk));if(len<0)-die_errno("cannot readlink '%s'",template);+die_errno(_("cannot readlink '%s'"),template);if(sizeof(lnk)<=len)-die("insanely long symlink %s",template);+die(_("insanely long symlink %s"),template);lnk[len]=0;if(symlink(lnk,path))-die_errno("cannot symlink '%s' '%s'",lnk,path);+die_errno(_("cannot symlink '%s' '%s'"),lnk,path);}elseif(S_ISREG(st_template.st_mode)){if(copy_file(path,template,st_template.st_mode))-die_errno("cannot copy '%s' to '%s'",template,+die_errno(_("cannot copy '%s' to '%s'"),template,path);}else-error("ignoring template %s",template);+error(_("ignoring template %s"),template);}}
@@ -129,7 +129,7 @@ static void copy_templates(const char *template_dir)return;template_len=strlen(template_dir);if(PATH_MAX<=(template_len+strlen("/config")))-die("insanely long template path %s",template_dir);+die(_("insanely long template path %s"),template_dir);strcpy(template_path,template_dir);if(template_path[template_len-1]!='/'){template_path[template_len++]='/';
@@ -137,7 +137,7 @@ static void copy_templates(const char *template_dir)}dir=opendir(template_path);if(!dir){-warning("templates not found %s",template_dir);+warning(_("templates not found %s"),template_dir);return;}
@@ -150,8 +150,8 @@ static void copy_templates(const char *template_dir)if(repository_format_version&&repository_format_version!=GIT_REPO_VERSION){-warning("not copying templates of "-"a wrong format version %d from '%s'",+warning(_("not copying templates of "+"a wrong format version %d from '%s'"),repository_format_version,template_dir);closedir(dir);
@@ -443,18 +443,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)errno=EEXIST;/* fallthru */case-1:-die_errno("cannot mkdir %s",argv[0]);+die_errno(_("cannot mkdir %s"),argv[0]);break;default:break;}shared_repository=saved;if(mkdir(argv[0],0777)<0)-die_errno("cannot mkdir %s",argv[0]);+die_errno(_("cannot mkdir %s"),argv[0]);mkdir_tried=1;gotoretry;}-die_errno("cannot chdir to %s",argv[0]);+die_errno(_("cannot chdir to %s"),argv[0]);}}elseif(0<argc){usage(init_db_usage[0]);
@@ -476,8 +476,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)git_dir=getenv(GIT_DIR_ENVIRONMENT);if((!git_dir||is_bare_repository_cfg==1)&&getenv(GIT_WORK_TREE_ENVIRONMENT))-die("%s (or --work-tree=<directory>) not allowed without "-"specifying %s (or --git-dir=<directory>)",+die(_("%s (or --work-tree=<directory>) not allowed without "+"specifying %s (or --git-dir=<directory>)"),GIT_WORK_TREE_ENVIRONMENT,GIT_DIR_ENVIRONMENT);
@@ -502,10 +502,10 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)if(!git_work_tree_cfg){git_work_tree_cfg=xcalloc(PATH_MAX,1);if(!getcwd(git_work_tree_cfg,PATH_MAX))-die_errno("Cannot access current working directory");+die_errno(_("Cannot access current working directory"));}if(access(get_git_work_tree(),X_OK))-die_errno("Cannot access work tree '%s'",+die_errno(_("Cannot access work tree '%s'"),get_git_work_tree());}
By default xgettext(1) assumes that source code is in US-ASCII, change
that to UTF-8 for our case.
I'm not planning to include non-ASCII in any of the main Git interface
strings. But this'll be used for a gettext regression test to make
sure this works if we ever want to go this route, and to check that
the gettext implementation is sane in this regard.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Change the Makefile code to use a variable for the options that all
the xgettext(1) invocations are using. This makes it more readable,
and makes it easier to add more standard options.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Makefile | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
Change the git-init "Initialized empty Git repository" message and its
variants to use gettext.
This is one of the messages that could do with splitting up, I had a
WIP patch to do that that began like this:
const char *reinit_shared = _("Reinitialized existing shared Git repository in %s\n");
const char *init_shared = _("Initialized empty shared Git repository in %s\n");
const char *reinit_noshared = _("Reinitialized existing Git repository in %s\n");
const char *init_noshared = _("Initialized empty Git repository in %s\n");
But in the first round of gettextization I'm aiming to keep code
changes to a minimum for ease of review.
We can solicit input from translators about which messages that use
too much sprintf-ing are troublesome, and change those later.
Note that the TRANSLATORS comment doesn't use the usual Git
style. This is because everything from "/* TRANSLATORS: " to "*/" will
extracted as-is xgettext(1) and presented to translators, including
newlines and leading "*"'s. There seems to be no way to change that,
short of patching xgettext itself.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
builtin/init-db.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
@@ -348,9 +348,13 @@ int init_db(const char *template_dir, unsigned int flags)if(!(flags&INIT_DB_QUIET)){constchar*git_dir=get_git_dir();intlen=strlen(git_dir);-printf("%s%s Git repository in %s%s\n",-reinit?"Reinitialized existing":"Initialized empty",-shared_repository?" shared":"",++/* TRANSLATORS: The first '%s' is either "Reinitialized+existing" or "Initializedempty", the second "shared" or+"",andthelast'%s%s'istheverbatimdirectoryname.*/+printf(_("%s%s Git repository in %s%s\n"),+reinit?_("Reinitialized existing"):_("Initialized empty"),+shared_repository?_(" shared"):"",git_dir,len&&git_dir[len-1]!='/'?"/":"");}
Versions of Locale::Messages before 1.17 didn't have a $VERSION
variable. This caused test failures on boxes that had this old version
installed, since the warnings pragma emits warnings on STDERR, which
fails the test.
Change the test to work around this by first checking if the $VERSION
variable is defined before using it.
Reported-by: Jens Lehmann <redacted>
Tested-by: Jens Lehmann <redacted>
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t0202/test.pl | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
@@ -11,7 +11,9 @@ my $has_gettext_library = $Git::I18N::__HAS_LIBRARY;ok(1,"Testing Git::I18N version $Git::I18N::VERSION with ".($has_gettext_library-?"Locale::Messages version $Locale::Messages::VERSION"+?(defined$Locale::Messages::VERSION+?"Locale::Messages version $Locale::Messages::VERSION"+:"Locale::Messages version <1.17"):"NO Perl gettext library"));ok(1,"Git::I18N is located at $INC{'Git/I18N.pm'}");
Add tests for message re-encoding under C. Unlike the Shell tests
these tests will break under GNU libintl if the recent patch to
gettext.c is reverted. So this serves as a regression test for that
issue.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t0204-gettext-reencode-sanity.sh | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
Add a GETTEXT_ISO_LOCALE prerequisite to lib-gettext.sh, it'll be set
if we have an is_IS.ISO-8859-1 locale.
This is needed for an upcoming test that checks if our gettext library
can recode our UTF-8 po/is.po to is_IS.ISO-8859-1 on request.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/lib-gettext.sh | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
@@ -18,9 +18,15 @@ thenpq}')-# Export it as an environmental variable so the t0202/test.pl Perl-# test can use it too-exportis_IS_locale+# is_IS.ISO8859-1 on Solaris and FreeBSD, is_IS.iso88591 on Debian+is_IS_iso_locale=$(locale-a|sed-n'/^is_IS\.[iI][sS][oO]8859-*1$/{+p+q+}')++# Export them as an environmental variable so the t0202/test.pl+# Perl test can use it too+exportis_IS_localeis_IS_iso_localeiftest-n"$is_IS_locale"&&test$GIT_INTERNAL_GETTEXT_SH_SCHEME!="fallthrough"
@@ -35,6 +41,20 @@ thenelsesay"# lib-gettext: No is_IS UTF-8 locale available"fi++iftest-n"$is_IS_iso_locale"&&+test$GIT_INTERNAL_GETTEXT_SH_SCHEME!="fallthrough"+then+# Some of the tests need the reference Icelandic locale+test_set_prereqGETTEXT_ISO_LOCALE++# Exporting for t0202/test.pl+GETTEXT_ISO_LOCALE=1+exportGETTEXT_ISO_LOCALE+say"# lib-gettext: Found '$is_IS_iso_locale' as a is_IS ISO-8859-1 locale"+else+say"# lib-gettext: No is_IS ISO-8859-1 locale available"+fielse# Only run some tests when we don't have gettext supporttest_set_prereqNO_GETTEXT
This was the only message in t/t0200/* that didn't have a TRANSLATORS
comment, without it translators will waste time translating this
needlessly.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t0200/test.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
@@ -1,6 +1,7 @@/* This is a phony C program that's only here to test xgettext message extraction */constcharhelp[]=+/* TRANSLATORS: This is a test. You don't need to translate it. */N_("See 'git help COMMAND' for more information on a specific command.");intmain(void)
Change the gettext setup code to arrange for messages to be emitted in
the user's requested encoding, but avoid setting LC_CTYPE from the
environment for the whole program.
In 107880a I removed our use of setlocale(LC_CTYPE, "") because of a
bug in the GNU C Library [1]. Even if it wasn't for that bug we
wouldn't want to use LC_CTYPE at this point, because it'd require
auditing all the code that uses C functions whose semantics are
modified by LC_CTYPE.
But only setting LC_MESSAGES as we do creates a problem, since we
declare the encoding of our PO files[2] the gettext implementation
will try to recode it to the user's locale, but without LC_CTYPE it'll
emit something like this on 'git init'
Bj? til t?ma Git lind ? /hl/agh/.git/
Gettext knows about the encoding of our PO file, but we haven't told
it about the user's encoding, so all the non-US-ASCII characters get
encoded to question marks.
But we're in luck! We can set LC_CTYPE from the environment only while
we call nl_langinfo and bind_textdomain_codeset. That suffices to tell
gettext what encoding it should emit in, so it'll now say:
Bjó til tóma Git lind í /hl/agh/.git/
And the equivalent ISO-8859-1 string will be emitted under a
ISO-8859-1 locale.
With this change way we get the advantages of setting LC_CTYPE (talk
to the user in his language/encoding), without the drawbacks (changed
semantics for C functions we rely on).
In the long term we should probably see about getting that bug in
glibc fixed, and audit our code so it won't fall apart under a non-C
locale.
1. http://sourceware.org/bugzilla/show_bug.cgi?id=6530
2. E.g. "Content-Type: text/plain; charset=UTF-8\n" in po/is.po
Suggested-by: Jonathan Nieder <redacted>
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
gettext.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
Change is.po to use the header order added by msgmerge(1), this'll
make subsequent diffs to it smaller and easier to manage. While I'm at
it add a Language header indicating that the file is in
Icelandic.
When we add more *.po files later we should add a Language header to
those as well.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
po/is.po | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
Change builtin.h to include gettext.h. This is needed in order to
translate Git's builtin commands (like git-init), which don't include
gettext.h otherwise.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
builtin.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
A test that tests that calling gettext on a UTF-8 msgid works, and
that recoding the resulting string works too.
This test uses the --from-code=UTF-8 xgettext(1) argument introduced
in an earlier patch.
This patch only tests the shellscript portion of our gettext
interface. I can't get any of these tests to fail on any of the
gettext implementations I have around, even without the previous patch
to gettext.c. But having exhaustive tests in this area is good
regardless.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
po/is.po | 6 ++++++
t/t0200/test.c | 3 +++
t/t0204-gettext-reencode-sanity.sh | 21 +++++++++++++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)
@@ -37,6 +37,12 @@ msgid "TEST: Old English Runes"msgstr"TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ"#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:21+#, c-format+msgid"TEST: ‘single’ and “double” quotes"+msgstr"TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir"++#. TRANSLATORS: This is a test. You don't need to translate it.#: t/t0200/test.sh:8msgid"TEST: A Shell test string"msgstr"TILRAUN: Skeljartilraunastrengur"
@@ -16,4 +16,7 @@ int main(void)/* TRANSLATORS: This is a test. You don't need to translate it. */printf(_("TEST: Old English Runes"));++/* TRANSLATORS: This is a test. You don't need to translate it. */+printf(_("TEST: ‘single’ and “double” quotes"));}
@@ -40,4 +40,25 @@ test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTfi'+test_expect_successGETTEXT_LOCALE'gettext: Fetching a UTF-8 msgid -> UTF-8''+printf"TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir">expect&&+LANGUAGE=isLC_ALL="$is_IS_locale"gettext"TEST: ‘single’ and “double” quotes">actual&&+test_cmpexpectactual+'++# How these quotes get transliterated depends on the gettext implementation:+#+# Debian: ,einfaldar' og ,,tvöfaldar" [GNU libintl]+# FreeBSD: `einfaldar` og "tvöfaldar" [GNU libintl]+# Solaris: ?einfaldar? og ?tvöfaldar? [Solaris libintl]+#+# Just make sure the contents are transliterated, and don't use grep -q+# so that these differences are emitted under --verbose for curious+# eyes.+test_expect_successGETTEXT_ISO_LOCALE'gettext: Fetching a UTF-8 msgid -> ISO-8859-1''+LANGUAGE=isLC_ALL="$is_IS_iso_locale"gettext"TEST: ‘single’ and “double” quotes">actual&&+grep"einfaldar"actual&&+grep"$(echotvöfaldar|iconv-fUTF-8-tISO8859-1)"actual+'+ test_done
From: Marcin Cieślak <redacted>
Translate all the translatable messages currently in Git, except for
the 10 TEST messages that shouldn't be translated.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Marcin Cieślak <redacted>
---
po/pl.po | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 187 insertions(+), 0 deletions(-)
create mode 100644 po/pl.po
@@ -0,0 +1,187 @@+msgid""+msgstr""+"Project-Id-Version: Git\n"+"Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"+"POT-Creation-Date: 2010-08-30 18:16+0000\n"+"PO-Revision-Date: 2010-08-30 17:02+0200\n"+"Last-Translator: Marcin Cieślak <saper@saper.info>\n"+"Language-Team: Git Mailing List <git@vger.kernel.org>\n"+"Language: pl\n"+"MIME-Version: 1.0\n"+"Content-Type: text/plain; charset=UTF-8\n"+"Content-Transfer-Encoding: 8bit\n"+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"++#: builtin/init-db.c:34+#, c-format+msgid"Could not make %s writable by group"+msgstr"Nie mogę dać prawa zapisu grupie w %s"++#: builtin/init-db.c:61+#, c-format+msgid"insanely long template name %s"+msgstr"beznadziejnie długa nazwa szablonu %s"++#: builtin/init-db.c:66+#, c-format+msgid"cannot stat '%s'"+msgstr"nie mogę tknąć '%s'"++#: builtin/init-db.c:72+#, c-format+msgid"cannot stat template '%s'"+msgstr"nie mogę tknąć szablonu '%s'"++#: builtin/init-db.c:79+#, c-format+msgid"cannot opendir '%s'"+msgstr"nie mogę otworzyć katalogu '%s'"++#: builtin/init-db.c:96+#, c-format+msgid"cannot readlink '%s'"+msgstr"readlink nie zadziałało dla '%s'"++#: builtin/init-db.c:98+#, c-format+msgid"insanely long symlink %s"+msgstr"beznadziejnie długi link symboliczny %s"++#: builtin/init-db.c:101+#, c-format+msgid"cannot symlink '%s' '%s'"+msgstr"nie mogę założyć symbolicznego link z '%s' do '%s'"++#: builtin/init-db.c:105+#, c-format+msgid"cannot copy '%s' to '%s'"+msgstr"nie mogę skopiować '%s' to '%s'"++#: builtin/init-db.c:109+#, c-format+msgid"ignoring template %s"+msgstr"pomijam szablon %s"++#: builtin/init-db.c:132+#, c-format+msgid"insanely long template path %s"+msgstr"beznadziejnie długa śieżka do wzorca %s"++#: builtin/init-db.c:140+#, c-format+msgid"templates not found %s"+msgstr"nie znaleziono szablonów %s"++#: builtin/init-db.c:153+#, c-format+msgid"not copying templates of a wrong format version %d from '%s'"+msgstr"nie będę kopiować szablonów oznaczonych niewłaściwym numerem wersji %d z '%s'"++#: builtin/init-db.c:191+#, c-format+msgid"insane git directory %s"+msgstr"beznadziejny katalog gita %s"++#. TRANSLATORS: The first '%s' is either "Reinitialized+#. existing" or "Initialized empty", the second " shared" or+#. "", and the last '%s%s' is the verbatim directory name.+#: builtin/init-db.c:355+#, c-format+msgid"%s%s Git repository in %s%s\n"+msgstr"%s%s repozytorium Gita w %s%s\n"++#: builtin/init-db.c:356+msgid"Reinitialized existing"+msgstr"Ponownie zainicjowałem istniejące"++#: builtin/init-db.c:356+msgid"Initialized empty"+msgstr"Utworzyłem puste"++#: builtin/init-db.c:357+msgid" shared"+msgstr" współdzielone"++#: builtin/init-db.c:376+msgid"cannot tell cwd"+msgstr"nie wiem w którym katalogu jestem"++#: builtin/init-db.c:450 builtin/init-db.c:457+#, c-format+msgid"cannot mkdir %s"+msgstr"nie mogę utworzyć katalogu %s"++#: builtin/init-db.c:461+#, c-format+msgid"cannot chdir to %s"+msgstr"nie mogę wejść do katalogu %s"++#: builtin/init-db.c:483+#, c-format+msgid"%s (or --work-tree=<directory>) not allowed without specifying %s (or --git-dir=<directory>)"+msgstr"nie można użyć %s (or --work-tree=<katalog>) bez podania %s (or --git-dir=<katalog>)"++#: builtin/init-db.c:509+msgid"Cannot access current working directory"+msgstr"Nie mogę dobrać się do bieżącego katalogu"++#: builtin/init-db.c:512+#, c-format+msgid"Cannot access work tree '%s'"+msgstr"Nie mogę dostać się do drzewa roboczego '%s'"++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:5+msgid"See 'git help COMMAND' for more information on a specific command."+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:10+msgid"TEST: A C test string"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:13+#, c-format+msgid"TEST: A C test string %s"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:16+#, c-format+msgid"TEST: Hello World!"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:19+#, c-format+msgid"TEST: Old English Runes"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:22+#, c-format+msgid"TEST: ‘single’ and “double” quotes"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.sh:8+msgid"TEST: A Shell test string"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.sh:11+#, sh-format+msgid"TEST: A Shell test $variable"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.perl:8+msgid"TEST: A Perl test string"+msgstr""++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.perl:11+#, perl-format+msgid"TEST: A Perl test variable %s"+msgstr""
@@ -11,35 +11,154 @@ msgstr """Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"-#: t/t0200/test.c:4+#: builtin/init-db.c:34+#, c-format+msgid"Could not make %s writable by group"+msgstr"Gat ekki gert %s skrifanlega af hóp"++#: builtin/init-db.c:61+#, c-format+msgid"insanely long template name %s"+msgstr"brjálæðislega langt sniðsnafn %s"++#: builtin/init-db.c:66+#, c-format+msgid"cannot stat '%s'"+msgstr"gat ekki stat-að '%s'"++#: builtin/init-db.c:72+#, c-format+msgid"cannot stat template '%s'"+msgstr"gat ekki stat-að sniðið '%s'"++#: builtin/init-db.c:79+#, c-format+msgid"cannot opendir '%s'"+msgstr"gat ekki opnað móppuna '%s'"++#: builtin/init-db.c:96+#, c-format+msgid"cannot readlink '%s'"+msgstr"gat ekki lesið tengilinn '%s'"++#: builtin/init-db.c:98+#, c-format+msgid"insanely long symlink %s"+msgstr"brjálæðislega langur tengill %s"++#: builtin/init-db.c:101+#, c-format+msgid"cannot symlink '%s' '%s'"+msgstr"gat ekki búið til tengilinn '%s' '%s'"++#: builtin/init-db.c:105+#, c-format+msgid"cannot copy '%s' to '%s'"+msgstr"gat ekki afritað '%s' til '%s'"++#: builtin/init-db.c:109+#, c-format+msgid"ignoring template %s"+msgstr"hunsa sniðið %s"++#: builtin/init-db.c:132+#, c-format+msgid"insanely long template path %s"+msgstr"brjálæðislega löng slóð á snið %s"++#: builtin/init-db.c:140+#, c-format+msgid"templates not found %s"+msgstr"sniðið fannst ekki %s"++#: builtin/init-db.c:153+#, c-format+msgid"not copying templates of a wrong format version %d from '%s'"+msgstr"aftira ekki sniðin vegna rangar útgáfu %d frá '%s'"++#: builtin/init-db.c:191+#, c-format+msgid"insane git directory %s"+msgstr"brjálúð git mappa %s"++#. TRANSLATORS: The first '%s' is either "Reinitialized+#. existing" or "Initialized empty", the second " shared" or+#. "", and the last '%s%s' is the verbatim directory name.+#: builtin/init-db.c:355+#, c-format+msgid"%s%s Git repository in %s%s\n"+msgstr"%s%s Git lind í %s%s\n"++#: builtin/init-db.c:356+msgid"Reinitialized existing"+msgstr"Endurgerði"++#: builtin/init-db.c:356+msgid"Initialized empty"+msgstr"Bjó til tóma"++#: builtin/init-db.c:357+msgid" shared"+msgstr" sameiginlega"++#: builtin/init-db.c:376+msgid"cannot tell cwd"+msgstr"finn ekki núverandi möppu"++#: builtin/init-db.c:450 builtin/init-db.c:457+#, c-format+msgid"cannot mkdir %s"+msgstr"gat ekki búið til möppuna %s"++#: builtin/init-db.c:461+#, c-format+msgid"cannot chdir to %s"+msgstr"get ekki farið inn í möppuna %s"++#: builtin/init-db.c:483+#, c-format+msgid"%s (or --work-tree=<directory>) not allowed without specifying %s (or --git-dir=<directory>)"+msgstr"%s (eða --work-tree=<mappa>) ekki leyfilegt ásamt %s (eða --git-dir=<mappa>)"++#: builtin/init-db.c:509+msgid"Cannot access current working directory"+msgstr"Get ekki opnað núverandi vinnumöppu"++#: builtin/init-db.c:512+#, c-format+msgid"Cannot access work tree '%s'"+msgstr"Get ekki opnað vinnutré '%s'"++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:5msgid"See 'git help COMMAND' for more information on a specific command."msgstr"Sjá 'git help SKIPUN' til að sjá hjálp fyrir tiltekna skipun."#. TRANSLATORS: This is a test. You don't need to translate it.-#: t/t0200/test.c:9+#: t/t0200/test.c:10msgid"TEST: A C test string"msgstr"TILRAUN: C tilraunastrengur"#. TRANSLATORS: This is a test. You don't need to translate it.-#: t/t0200/test.c:12+#: t/t0200/test.c:13#, c-formatmsgid"TEST: A C test string %s"msgstr"TILRAUN: C tilraunastrengur %s"#. TRANSLATORS: This is a test. You don't need to translate it.-#: t/t0200/test.c:15+#: t/t0200/test.c:16#, c-formatmsgid"TEST: Hello World!"msgstr"TILRAUN: Halló Heimur!"#. TRANSLATORS: This is a test. You don't need to translate it.-#: t/t0200/test.c:18+#: t/t0200/test.c:19#, c-formatmsgid"TEST: Old English Runes"msgstr"TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ"#. TRANSLATORS: This is a test. You don't need to translate it.-#: t/t0200/test.c:21+#: t/t0200/test.c:22#, c-formatmsgid"TEST: ‘single’ and “double” quotes"msgstr"TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir"
Change the invocations of xgettext to use the --msgid-bugs-address
option. This has the effect of adding a Report-Msgid-Bugs-To header to
the git.pot and the derived *.po files. Doing so is recommended by the
gettext manual.
If this isn't added the Report-Msgid-Bugs-To header already in
po/is.po and other PO files will be removed by msgmerge(1).
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Our PO files are written in UTF-8, but We're not using
setlocale(LC_CTYPE, "") so it's not a given that someone with e.g. a
ISO-8859-1 locale will get messages in ISO-8859-1, and not UTF-8.
Introduce a new test to test for this, it uses the recently added
GETTEXT_ISO_LOCALE prerequisite.
This patch only tests the shellscript portion of our gettext
interface. I can't get any of these tests to fail on any of the
gettext implementations I have around, even without the previous patch
to gettext.c. But having exhaustive tests in this area is good
regardless.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
po/is.po | 12 ++++++++++
t/t0200/test.c | 6 +++++
t/t0204-gettext-reencode-sanity.sh | 43 ++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 0 deletions(-)
create mode 100755 t/t0204-gettext-reencode-sanity.sh
@@ -25,6 +25,18 @@ msgid "TEST: A C test string %s"msgstr"TILRAUN: C tilraunastrengur %s"#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:15+#, c-format+msgid"TEST: Hello World!"+msgstr"TILRAUN: Halló Heimur!"++#. TRANSLATORS: This is a test. You don't need to translate it.+#: t/t0200/test.c:18+#, c-format+msgid"TEST: Old English Runes"+msgstr"TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ"++#. TRANSLATORS: This is a test. You don't need to translate it.#: t/t0200/test.sh:8msgid"TEST: A Shell test string"msgstr"TILRAUN: Skeljartilraunastrengur"
@@ -10,4 +10,10 @@ int main(void)/* TRANSLATORS: This is a test. You don't need to translate it. */printf(_("TEST: A C test string %s"),"variable");++/* TRANSLATORS: This is a test. You don't need to translate it. */+printf(_("TEST: Hello World!"));++/* TRANSLATORS: This is a test. You don't need to translate it. */+printf(_("TEST: Old English Runes"));}
@@ -0,0 +1,43 @@+#!/bin/sh+#+# Copyright (c) 2010 Ævar Arnfjörð Bjarmason+#++test_description="Gettext reencoding of our *.po/*.mo files works"++../lib-gettext.sh+++test_expect_successGETTEXT_LOCALE'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Icelandic''+printf"TILRAUN: Halló Heimur!">expect&&+LANGUAGE=isLC_ALL="$is_IS_locale"gettext"TEST: Hello World!">actual&&+test_cmpexpectactual+'++test_expect_successGETTEXT_LOCALE'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes''+printf"TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ">expect&&+LANGUAGE=isLC_ALL="$is_IS_locale"gettext"TEST: Old English Runes">actual&&+test_cmpexpectactual+'++test_expect_successGETTEXT_ISO_LOCALE'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Icelandic''+printf"TILRAUN: Halló Heimur!"|iconv-fUTF-8-tISO8859-1>expect&&+LANGUAGE=isLC_ALL="$is_IS_iso_locale"gettext"TEST: Hello World!">actual&&+test_cmpexpectactual+'++test_expect_successGETTEXT_ISO_LOCALE'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Runes''+LANGUAGE=isLC_ALL="$is_IS_iso_locale"gettext"TEST: Old English Runes">runes&&++ifgrep"^TEST: Old English Runes$"runes+then+say"Your system can not handle this complexity and returns the string as-is"+else+# Both Solaris and GNU libintl will return this stream of+# question marks, so it is s probably portable enough+printf"TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????">runes-expect&&+test_cmprunes-expectrunes+fi+'++test_done
Change test.c to use '' quotes around "git help COMMAND" as git.c
does. An earlier version of the gettext series didn't use '' quotes,
but I hadn't run msgmerge since then so I didn't spot it.
For reference, the msgmerge command:
msgmerge --backup=off -U is.po git.pot
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
po/is.po | 4 ++--
t/t0200-gettext-basic.sh | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
@@ -10,8 +10,8 @@ msgstr """Content-Transfer-Encoding: 8bit\n"#: t/t0200/test.c:4-msgid"See git help COMMAND for more information on a specific command."-msgstr"Sjá git help SKIPUN til að sjá hjálp fyrir tiltekna skipun."+msgid"See 'git help COMMAND' for more information on a specific command."+msgstr"Sjá 'git help SKIPUN' til að sjá hjálp fyrir tiltekna skipun."#. TRANSLATORS: This is a test. You don't need to translate it.#: t/t0200/test.c:9
@@ -66,10 +66,10 @@ test_expect_success GETTEXT_LOCALE 'sanity: gettext(unknown) is passed through' test_expect_successGETTEXT_LOCALE'xgettext: C extraction of _() and N_() strings''printf"TILRAUN: C tilraunastrengur">expect&&printf"\n">>expect&&-printf"Sjá git help SKIPUN til að sjá hjálp fyrir tiltekna skipun.">>expect&&+printf"Sjá '\''git help SKIPUN'\'' til að sjá hjálp fyrir tiltekna skipun.">>expect&&LANGUAGE=isLC_ALL="$is_IS_locale"gettext"TEST: A C test string">actual&&printf"\n">>actual&&-LANGUAGE=isLC_ALL="$is_IS_locale"gettext"See git help COMMAND for more information on a specific command.">>actual&&+LANGUAGE=isLC_ALL="$is_IS_locale"gettext"See '\''git help COMMAND'\'' for more information on a specific command.">>actual&&test_cmpexpectactual'
From: Peter Krefting <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason:
With it applied git-init is the one and only utility of the porcelain
that's translatable. The series includes a translation of it into
Icelandic and Polish.
Very interesting. I would like to contribute a Swedish translation as time
permits.
Any chance the translations could be co-ordinated through Translation
Project <URL:http://translationproject.org/>? I know I suggested this, and
was turned down, for gitk and git-gui, but this translation is potentially
larger and could benefit from the co-ordinated effort.
--
\\// Peter - http://www.softwolves.pp.se/
On Tue, Aug 31, 2010 at 11:08, Peter Krefting [off-list ref] wrote:
Ævar Arnfjörð Bjarmason:
quoted
With it applied git-init is the one and only utility of the porcelain
that's translatable. The series includes a translation of it into Icelandic
and Polish.
Very interesting. I would like to contribute a Swedish translation as time
permits.
Great!
Any chance the translations could be co-ordinated through Translation
Project <URL:http://translationproject.org/>? I know I suggested this, and
was turned down, for gitk and git-gui, but this translation is potentially
larger and could benefit from the co-ordinated effort.
Something like that would be welcome. Personally I'm happy with
editing *.po files locally with Emacs's po-mode, but to get more
translators we probably want a friendly web interface like that at
some point. Preferably with an active translation community.
I meant to look at this myself at some point, but if you could help
that'd be great!
The only reference I could find to a previous git +
translationproject.org discussion was this:
http://kerneltrap.org/mailarchive/git/2008/3/14/1163164 Is that the
one you're talking about?
I've used Launchpad somewhat for translating and it's friendly to
contributors & has an active community, but it seems to require that
we BSD-license our translations[1], which would be a showstopper since
we'd have to contact everyone who's been submitting GPL-2-only strings
to Git for the last 5 years.
Translationproject seems to have a similar requirement[2], but they
seem require you to send a letter to the FSF through snail mail before
you can contribute (maybe not, I didn't read all their docs
carefully). That would be a major hurdle to casual contributors.
1. https://help.launchpad.net/Translations/LicensingFAQ
2. http://translationproject.org/disclaim.txt
From: Peter Krefting <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason:
Something like that would be welcome. Personally I'm happy with editing
*.po files locally with Emacs's po-mode, but to get more translators we
probably want a friendly web interface like that at some point.
Well, it's not a web interface for translating, currently, just for keeping
track on what needs to be translated by whom (and for language teams to find
what to translate). You still edit the PO files in whatever you prefer.
Translationproject seems to have a similar requirement[2], but they seem
require you to send a letter to the FSF through snail mail before you can
contribute (maybe not, I didn't read all their docs carefully).
Only when you translate FSF software for which you need to send one of the
letters that claim that you are handing over copyright to the FSF. That is
not needed in this case, and translators working on such projects do not
need to send one.
For the project side, you bascially send a POT file every now and then,
between string-freeze and release, and update the PO files that come back
from the project every now and then. I've been using the system from both
sides and it's lightweight enough to be workable.
--
\\// Peter - http://www.softwolves.pp.se/
The long lines are a bit scary. :)
Maybe more of it could be pulled out into variables. As a
side-effect, users could override some settings from the command line.
Maybe something like this?
LOCALIZED_C = $(C_OBJ:o=c) t/t0200/test.c
LOCALIZED_SH = $(SCRIPT_SH) t/t0200/test.sh
LOCALIZED_PERL = $(SCRIPT_PERL) t/t0200/test.perl
XGETTEXT_OPTIONS = --add-comments
XGETTEXT_OPTIONS_C = $(XGETTEXT_OPTIONS) -k_ -kN_ -LC
XGETTEXT_OPTIONS_SH = $(XGETTEXT_OPTIONS) -LShell
XGETTEXT_OPTIONS_PERL = $(XGETTEXT_OPTIONS) -k__ -LPerl
po/git.pot:
rm -f $@+
$(XGETTEXT) -o$@+ $(XGETTEXT_OPTIONS_C) $(LOCALIZED_C)
$(XGETTEXT) -j -o$@+ $(XGETTEXT_OPTIONS_SH) $(LOCALIZED_SH)
$(XGETTEXT) -j -o$@+ $(XGETTEXT_OPTIONS_PERL) $(LOCALIZED_PERL)
mv $@+ $@
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason wrote:
quoted hunk
--- a/builtin/init-db.c+++ b/builtin/init-db.c
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)}}elseif(share&&adjust_shared_perm(dir))-die("Could not make %s writable by group",dir);+die(_("Could not make %s writable by group"),dir);
Sensible.
I wonder if die() should not just be taught to automatically look up
translations for its format string (could gettext handle that?).
Although we try not to change plumbing error messages without good
reason, details of error messages change often enough that imvho
scripts should not be relying on them.
- die_errno("cannot stat '%s'", path);
+ die_errno(_("cannot stat '%s'"), path);
Will strerror() cope correctly without LC_CTYPE set up? (Not part
of this series, just something I was reminded of.)
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason wrote:
Note that the TRANSLATORS comment doesn't use the usual Git
style. This is because everything from "/* TRANSLATORS: " to "*/" will
extracted as-is xgettext(1) and presented to translators, including
newlines and leading "*"'s.
How would it cope with the following?
/* TRANSLATORS:
* The first '%s' is either "Reinitialized existing" or
* "Initialized empty", the second " shared" or "", and
* the last '%s%s' is the verbatim directory name.
*/
The leading column of stars makes it easier to distinguish code
from comments. (Plus I am not too happy to read code with two
inconsistent comment styles used.)
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason wrote:
In 107880a I removed our use of setlocale(LC_CTYPE, "") because of a
bug in the GNU C Library [1]
Future readers might benefit from a reminder that it is vsnprintf that
is broken.
Aside, not about this patch: glibc printf can be very convenient for
translators, because of format strings like "%4$s". Do other common
platforms like FreeBSD and Mingw have something similar?
For the curious: we cannot use
setlocale(LC_CTYPE, "");
charset = nl_langinfo(CODESET);
setlocale(LC_CTYPE, "C");
bind_textdomain_codeset("git", charset);
because nl_langinfo returns a pointer to a static buffer that might
be wiped out by setlocale() iirc.
Thanks.
Is there a diff driver that will ignore these --add-location lines?
Alternatively, would it be possible to get msgmerge and xgettext to
provide the filenames without the line numbers? My experience is
that most translation diffs are very hard to read because about 80%
noise. :(
Aside from that, this looks good and sane (well, the English part
I can read does).
}
}
else if (share && adjust_shared_perm(dir))
- die("Could not make %s writable by group", dir);
+ die(_("Could not make %s writable by group"), dir);
Sensible.
I wonder if die() should not just be taught to automatically look up
translations for its format string (could gettext handle that?).
It's always a two step process. First you have to mark the messages
for translation, then you have to call gettext() (or _())on them to
make a lookup in the message catalog.
The only way that could work is if I taught xgettext to extract
strings passed to die(), but then managing the false positives would
probably be more effort than just marking them manually, and it would
be a big load on the translators:
$ ack 'die\("(.*?)"' --output '$1' *[ch] builtin/*[ch] | sort -u | wc -l
1153
Although we try not to change plumbing error messages without good
reason, details of error messages change often enough that imvho
scripts should not be relying on them.
quoted
- die_errno("cannot stat '%s'", path);
+ die_errno(_("cannot stat '%s'"), path);
Will strerror() cope correctly without LC_CTYPE set up? (Not part
of this series, just something I was reminded of.)
My GNU/Linux strerror(3) claims to use LC_MESSAGES, but I didn't test
it.
From: Marcin Cieslak <hidden> Date: 2016-06-15 22:49:25
On Tue, 31 Aug 2010, Jonathan Nieder wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
In 107880a I removed our use of setlocale(LC_CTYPE, "") because of a
bug in the GNU C Library [1]
Future readers might benefit from a reminder that it is vsnprintf that
is broken.
Aside, not about this patch: glibc printf can be very convenient for
translators, because of format strings like "%4$s". Do other common
platforms like FreeBSD and Mingw have something similar?
Speaking for FreeBSD:
% svn log -r21674 printf.3
------------------------------------------------------------------------
r21674 | jkh | 1997-01-14 08:31:39 +0100 (wto) | 8 linii
The following patch to lib/libc/stdio implements positional arguments in
a manner consistent with other implementations. Its done in a way that
adds only a tiny amount of overhead when positional arguments are not used.
I also have a test program to go with this, but don't know where it belongs
in the tree.
Submitted-By: Bill Fenner [off-list ref]
------------------------------------------------------------------------
Solaris 9 has it, too.
--Marcin
On Tue, Aug 31, 2010 at 15:10, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
Note that the TRANSLATORS comment doesn't use the usual Git
style. This is because everything from "/* TRANSLATORS: " to "*/" will
extracted as-is xgettext(1) and presented to translators, including
newlines and leading "*"'s.
How would it cope with the following?
/* TRANSLATORS:
* The first '%s' is either "Reinitialized existing" or
* "Initialized empty", the second " shared" or "", and
* the last '%s%s' is the verbatim directory name.
*/
The leading column of stars makes it easier to distinguish code
from comments. (Plus I am not too happy to read code with two
inconsistent comment styles used.)
As I was (trying) to get across in the the commit message it'll make
the *'s part of the message. I.e.:
TRANSLATORS: * The first '%s' is either "Reinitialized existing"
or * "Initialized empty", the second " shared" or "", and * the
last '%s%s' is the verbatim directory name.
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason wrote:
The only way that could work is if I taught xgettext to extract
strings passed to die(), but then managing the false positives would
probably be more effort than just marking them manually, and it would
be a big load on the translators:
$ ack 'die\("(.*?)"' --output '$1' *[ch] builtin/*[ch] | sort -u | wc -l
1153
To pursue this a little further: would there be any false positives?
We could avoid overwhelming translators by waiting until a file has
been fulling gettextized before allowing xgettext to scavenge it
(i.e., temporarily using a hard-coded list of files in the xgettext
invocation).
quoted
Will strerror() cope correctly without LC_CTYPE set up? (Not part
of this series, just something I was reminded of.)
My GNU/Linux strerror(3) claims to use LC_MESSAGES, but I didn't test
it.
Sounds like no, then.
$ cat foo.c
#include <stdio.h>
#include <locale.h>
#include <errno.h>
int main(void)
{
setlocale(LC_ALL, "");
setlocale(LC_CTYPE, "C");
errno = ENODEV;
perror("test");
return 0;
}
$ make foo
cc foo.c -o foo
$ ./foo
test: No such device
$ LANG=de_DE.UTF-8 ./foo
test: Kein passendes Ger?t gefunden
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason wrote:
quoted
Ævar Arnfjörð Bjarmason wrote:
quoted
quoted
This is because everything from "/* TRANSLATORS: " to "*/" will
extracted as-is xgettext(1) and presented to translators, including
newlines and leading "*"'s.
[...]
As I was (trying) to get across in the the commit message it'll make
the *'s part of the message. I.e.:
TRANSLATORS: * The first '%s' is either "Reinitialized existing"
or * "Initialized empty", the second " shared" or "", and * the
last '%s%s' is the verbatim directory name.
Ah, so you meant "not including newlines but including leading '*''s".
Hmm, this is annoying. Searching existing projects, it seems that
a lot of people are just not using the TRANSLATORS: feature except
for one-line comments.
Thanks for the explanation.
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:25
Marcin Cieslak wrote:
Speaking for FreeBSD:
% svn log -r21674 printf.3 ------------------------------------------------------------------------
r21674 | jkh | 1997-01-14 08:31:39 +0100 (wto) | 8 linii
The following patch to lib/libc/stdio implements positional arguments in
a manner consistent with other implementations.
On Tue, Aug 31, 2010 at 15:44, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
The only way that could work is if I taught xgettext to extract
strings passed to die(), but then managing the false positives would
probably be more effort than just marking them manually, and it would
be a big load on the translators:
$ ack 'die\("(.*?)"' --output '$1' *[ch] builtin/*[ch] | sort -u | wc -l
1153
To pursue this a little further: would there be any false positives?
Maybe I can see a few probable plumbing messages here, but probably
nothing that's unmanagable: http://gist.github.com/559255
We could avoid overwhelming translators by waiting until a file has
been fulling gettextized before allowing xgettext to scavenge it
(i.e., temporarily using a hard-coded list of files in the xgettext
invocation).
Yeah we could go this route. But I'm a bit uneasy about it. The way
I'm doing it now I have to manually look at every message to determine
if it's a porcelain error or not.
But it's easier to accidentally mark something with a filelist like
that, or to mark a future plumbing die message that gets introduced
after a file has made the OK list.
Maybe we should have die_plumbing() and die_porcelain() functions to
indicate the nature of the message, although we could get the same
thing with die() and die(_()) once I'm done.
quoted
quoted
Will strerror() cope correctly without LC_CTYPE set up? (Not part
of this series, just something I was reminded of.)
My GNU/Linux strerror(3) claims to use LC_MESSAGES, but I didn't test
it.
Sounds like no, then.
$ cat foo.c
#include <stdio.h>
#include <locale.h>
#include <errno.h>
int main(void)
{
setlocale(LC_ALL, "");
setlocale(LC_CTYPE, "C");
errno = ENODEV;
perror("test");
return 0;
}
$ make foo
cc foo.c -o foo
$ ./foo
test: No such device
$ LANG=de_DE.UTF-8 ./foo
test: Kein passendes Ger?t gefunden
What about with MESSAGES instead of ALL, like we're doing?
setlocale(LC_MESSAGES, "");
setlocale(LC_CTYPE, "C");
I don't have a box here with a localized C library to test it on.
The long lines are a bit scary. :)
Maybe more of it could be pulled out into variables. As a
side-effect, users could override some settings from the command line.
Maybe something like this?
LOCALIZED_C = $(C_OBJ:o=c) t/t0200/test.c
LOCALIZED_SH = $(SCRIPT_SH) t/t0200/test.sh
LOCALIZED_PERL = $(SCRIPT_PERL) t/t0200/test.perl
XGETTEXT_OPTIONS = --add-comments
XGETTEXT_OPTIONS_C = $(XGETTEXT_OPTIONS) -k_ -kN_ -LC
XGETTEXT_OPTIONS_SH = $(XGETTEXT_OPTIONS) -LShell
XGETTEXT_OPTIONS_PERL = $(XGETTEXT_OPTIONS) -k__ -LPerl
po/git.pot:
rm -f $@+
$(XGETTEXT) -o$@+ $(XGETTEXT_OPTIONS_C) $(LOCALIZED_C)
$(XGETTEXT) -j -o$@+ $(XGETTEXT_OPTIONS_SH) $(LOCALIZED_SH)
$(XGETTEXT) -j -o$@+ $(XGETTEXT_OPTIONS_PERL) $(LOCALIZED_PERL)
mv $@+ $@
On Tue, Aug 31, 2010 at 15:18, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
In 107880a I removed our use of setlocale(LC_CTYPE, "") because of a
bug in the GNU C Library [1]
Future readers might benefit from a reminder that it is vsnprintf that
is broken.
I'll work something in about that.
Aside, not about this patch: glibc printf can be very convenient for
translators, because of format strings like "%4$s". Do other common
platforms like FreeBSD and Mingw have something similar?
I certainly hope so. I was planning on documenting its usage,
Johannes?
For the curious: we cannot use
setlocale(LC_CTYPE, "");
charset = nl_langinfo(CODESET);
setlocale(LC_CTYPE, "C");
bind_textdomain_codeset("git", charset);
because nl_langinfo returns a pointer to a static buffer that might
be wiped out by setlocale() iirc.
But I'm hopefully sidestepping that issue by passing it to
bind_textdomain_codeset() right away.
Is there a diff driver that will ignore these --add-location lines?
Alternatively, would it be possible to get msgmerge and xgettext to
provide the filenames without the line numbers? My experience is
that most translation diffs are very hard to read because about 80%
noise. :(
Aside from that, this looks good and sane (well, the English part
I can read does).
Some context, an earlier discussion on this:
http://kerneltrap.org/mailarchive/git/2010/5/30/31415/thread#mid-31415
Removing them will have some negative effects. Gettext uses them for
its message fuzzying logic, and they enable you to jump directly to a
source definition.
I've found that it's easier to just go with the flow as far as the
gettext tools are concerned, and they seem to really like to have
these line numbers in :)
Is there a diff driver that will ignore these --add-location lines?
Alternatively, would it be possible to get msgmerge and xgettext to
provide the filenames without the line numbers? My experience is
that most translation diffs are very hard to read because about 80%
noise. :(
Aside from that, this looks good and sane (well, the English part
I can read does).
msgmerge and xgettext does seem to have the --no-location flag to
avoid these annotations from being generated. The documentation does
say "Note that using this option makes it harder for technically
skilled translators to understand each message's context. ", though.
But perhaps the annotated versions could be generated when needed and
never checked-in (similar to what you suggested in that e-mail)? It
sounds to me like that would give us the best of all worlds. If it's
possible, that is.
Is there a diff driver that will ignore these --add-location lines?
Alternatively, would it be possible to get msgmerge and xgettext to
provide the filenames without the line numbers? My experience is
that most translation diffs are very hard to read because about 80%
noise. :(
Aside from that, this looks good and sane (well, the English part
I can read does).
msgmerge and xgettext does seem to have the --no-location flag to
avoid these annotations from being generated. The documentation does
say "Note that using this option makes it harder for technically
skilled translators to understand each message's context. ", though.
But perhaps the annotated versions could be generated when needed and
never checked-in (similar to what you suggested in that e-mail)? It
sounds to me like that would give us the best of all worlds. If it's
possible, that is.
It's certainly possible. But each time you worked with these files
you'd have add the line numbers yourself to generate the context, then
translate, then remove them again, then submit your patch.
I just think it's overly tedious work for getting smaller diffs.
Is there a diff driver that will ignore these --add-location lines?
Alternatively, would it be possible to get msgmerge and xgettext to
provide the filenames without the line numbers? My experience is
that most translation diffs are very hard to read because about 80%
noise. :(
Aside from that, this looks good and sane (well, the English part
I can read does).
msgmerge and xgettext does seem to have the --no-location flag to
avoid these annotations from being generated. The documentation does
say "Note that using this option makes it harder for technically
skilled translators to understand each message's context. ", though.
But perhaps the annotated versions could be generated when needed and
never checked-in (similar to what you suggested in that e-mail)? It
sounds to me like that would give us the best of all worlds. If it's
possible, that is.
It's certainly possible. But each time you worked with these files
you'd have add the line numbers yourself to generate the context, then
translate, then remove them again, then submit your patch.
I just think it's overly tedious work for getting smaller diffs.
You know, computers are pretty good at automating tedious jobs ;)
I was thinking something along the lines of having po/is.po etc, and
generating po/is.ann.po (or something) from these (+source) so
translators can see the text in the context of the code. That is, they
edit is.po, and generate is.ann.po when they want to see the context.
Then we can put *.ann.po in .gitignore, and it's really just a matter
of editing, doing "make po/is.ann.po", and voila.
But I dunno, I haven't been using these tools much myself.
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:25
Ævar Arnfjörð Bjarmason wrote:
On Tue, Aug 31, 2010 at 15:18, Jonathan Nieder [off-list ref] wrote:
quoted
Aside, not about this patch: glibc printf can be very convenient for
translators, because of format strings like "%4$s". Do other common
platforms like FreeBSD and Mingw have something similar?
I certainly hope so. I was planning on documenting its usage,
Johannes?
From: Erik Faye-Lund <hidden> Date: 2016-06-15 22:49:25
On Wed, Sep 1, 2010 at 12:45 AM, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
On Tue, Aug 31, 2010 at 15:18, Jonathan Nieder [off-list ref] wrote:
quoted
quoted
Aside, not about this patch: glibc printf can be very convenient for
translators, because of format strings like "%4$s". Do other common
platforms like FreeBSD and Mingw have something similar?
I certainly hope so. I was planning on documenting its usage,
Johannes?
Sorry, my knowledge was just outdated. It's in posix[1] now, which
I think means we can expect it to be in any recent libc.
Unfortunately msys uses newlib 1.9.0 afaict, from 2001. The %4$s
support was introduced[2] to newlib by Eric Blake on 2007-04-25.
Git for Windows doesn't use the MSYS-runtime for Git itself, it only
use the MSYS-environment to build etc. It's using MSVCRT.DLL as the
CRT, which is even worse feature-wise.
http://msdn.microsoft.com/en-us/library/56e442dc.aspx describes the
format specification fields supported, and it does not look promising.