[PATCH/RFC 00/17] Begin gettextizing Git

STALE3733d

44 messages, 5 authors, 2016-06-15 · open the first message on its own page

[PATCH/RFC 00/17] Begin gettextizing Git

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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

[PATCH/RFC 05/17] gettext: make the simple parts of git-init localizable

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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(-)
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 0271285..9c08985 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)
 		}
 	}
 	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);
 }
 
 static void copy_templates_1(char *path, int baselen,
@@ -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);
 		}
 		else
 			exists = 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);
 			int baselen_sub = baselen + namelen;
 			int template_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,
 			int len;
 			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);
 		}
 		else if (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);
@@ -188,7 +188,7 @@ static int create_default_files(const char *template_path)
 	int filemode;
 
 	if (len > sizeof(path)-50)
-		die("insane git directory %s", git_dir);
+		die(_("insane git directory %s"), git_dir);
 	memcpy(path, git_dir, len);
 
 	if (len && path[len-1] != '/')
@@ -369,7 +369,7 @@ static int guess_repository_type(const char *git_dir)
 	if (!strcmp(".", git_dir))
 		return 1;
 	if (!getcwd(cwd, sizeof(cwd)))
-		die_errno("cannot tell cwd");
+		die_errno(_("cannot tell cwd"));
 	if (!strcmp(git_dir, cwd))
 		return 1;
 	/*
@@ -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;
 				goto retry;
 			}
-			die_errno("cannot chdir to %s", argv[0]);
+			die_errno(_("cannot chdir to %s"), argv[0]);
 		}
 	} else if (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());
 	}
 
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 03/17] Makefile: tell xgettext(1) that our source is in UTF-8

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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(-)
diff --git a/Makefile b/Makefile
index 4b46579..9818a59 100644
--- a/Makefile
+++ b/Makefile
@@ -2008,7 +2008,7 @@ cscope:
 	$(RM) cscope*
 	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 
-XGETTEXT_OPTIONS = --add-comments --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>"
+XGETTEXT_OPTIONS = --add-comments --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>" --from-code=UTF-8
 pot:
 	$(XGETTEXT) $(XGETTEXT_OPTIONS) --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
 	$(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 01/17] Makefile: A variable for options used by xgettext(1) calls

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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(-)
diff --git a/Makefile b/Makefile
index 62d526a..6a5bcf5 100644
--- a/Makefile
+++ b/Makefile
@@ -2008,10 +2008,11 @@ cscope:
 	$(RM) cscope*
 	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 
+XGETTEXT_OPTIONS = --add-comments
 pot:
-	$(XGETTEXT) --add-comments --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
-	$(XGETTEXT) --add-comments --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
-	$(XGETTEXT) --add-comments --join-existing --keyword=__ --output=po/git.pot --language=Perl $(SCRIPT_PERL) t/t0200/test.perl
+	$(XGETTEXT) $(XGETTEXT_OPTIONS) --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
+	$(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
+	$(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --keyword=__ --output=po/git.pot --language=Perl $(SCRIPT_PERL) t/t0200/test.perl
 
 POFILES := $(wildcard po/*.po)
 MOFILES := $(patsubst po/%.po,share/locale/%/LC_MESSAGES/git.mo,$(POFILES))
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 06/17] gettext: localize the main git-init message

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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(-)
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 9c08985..0224dee 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -348,9 +348,13 @@ int init_db(const char *template_dir, unsigned int flags)
 	if (!(flags & INIT_DB_QUIET)) {
 		const char *git_dir = get_git_dir();
 		int len = 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 "Initialized empty", the second " shared" or
+		   "", and the last '%s%s' is the verbatim directory name. */
+		printf(_("%s%s Git repository in %s%s\n"),
+		       reinit ? _("Reinitialized existing") : _("Initialized empty"),
+		       shared_repository ? _(" shared") : "",
 		       git_dir, len && git_dir[len-1] != '/' ? "/" : "");
 	}
 
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 08/17] gettext tests: test if $VERSION exists before using it

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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(-)
diff --git a/t/t0202/test.pl b/t/t0202/test.pl
index c2055fa..6b00603 100644
--- a/t/t0202/test.pl
+++ b/t/t0202/test.pl
@@ -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'}");
 
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 17/17] gettext tests: test message re-encoding under C

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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(-)
diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh
index 1a7ea37..189af90 100755
--- a/t/t0204-gettext-reencode-sanity.sh
+++ b/t/t0204-gettext-reencode-sanity.sh
@@ -61,4 +61,18 @@ test_expect_success GETTEXT_ISO_LOCALE 'gettext: Fetching a UTF-8 msgid -> ISO-8
     grep "$(echo tvöfaldar | iconv -f UTF-8 -t ISO8859-1)" actual
 '
 
+test_expect_success GETTEXT_LOCALE 'gettext.c: git init UTF-8 -> UTF-8' '
+    printf "Bjó til tóma Git lind" >expect &&
+    LANGUAGE=is LC_ALL="$is_IS_locale" git init repo >actual &&
+    test_when_finished "rm -rf repo" &&
+    grep "^$(cat expect) " actual
+'
+
+test_expect_success GETTEXT_ISO_LOCALE 'gettext.c: git init UTF-8 -> ISO-8859-1' '
+    printf "Bjó til tóma Git lind" >expect &&
+    LANGUAGE=is LC_ALL="$is_IS_iso_locale" git init repo >actual &&
+    test_when_finished "rm -rf repo" &&
+    grep "^$(cat expect | iconv -f UTF-8 -t ISO8859-1) " actual
+'
+
 test_done
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 10/17] gettext tests: add detection for is_IS.ISO-8859-1 locale

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:24

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(-)
diff --git a/t/lib-gettext.sh b/t/lib-gettext.sh
index f0cdd3d..4570ead 100644
--- a/t/lib-gettext.sh
+++ b/t/lib-gettext.sh
@@ -18,9 +18,15 @@ then
 		p
 		q
 	}')
-	# Export it as an environmental variable so the t0202/test.pl Perl
-	# test can use it too
-	export is_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
+	export is_IS_locale is_IS_iso_locale
 
 	if test -n "$is_IS_locale" &&
 		test $GIT_INTERNAL_GETTEXT_SH_SCHEME != "fallthrough"
@@ -35,6 +41,20 @@ then
 	else
 		say "# lib-gettext: No is_IS UTF-8 locale available"
 	fi
+
+	if test -n "$is_IS_iso_locale" &&
+		test $GIT_INTERNAL_GETTEXT_SH_SCHEME != "fallthrough"
+	then
+		# Some of the tests need the reference Icelandic locale
+		test_set_prereq GETTEXT_ISO_LOCALE
+
+		# Exporting for t0202/test.pl
+		GETTEXT_ISO_LOCALE=1
+		export GETTEXT_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"
+	fi
 else
 	# Only run some tests when we don't have gettext support
 	test_set_prereq NO_GETTEXT
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 13/17] gettext tests: mark a test message as not needing translation

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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(-)
diff --git a/t/t0200/test.c b/t/t0200/test.c
index ff15c2f..584d45c 100644
--- a/t/t0200/test.c
+++ b/t/t0200/test.c
@@ -1,6 +1,7 @@
 /* This is a phony C program that's only here to test xgettext message extraction */
 
 const char help[] =
+	/* TRANSLATORS: This is a test. You don't need to translate it. */
 	N_("See 'git help COMMAND' for more information on a specific command.");
 
 int main(void)
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 07/17] gettext.c: work around us not using setlocale(LC_CTYPE, "")

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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(-)
diff --git a/gettext.c b/gettext.c
index db99742..8644098 100644
--- a/gettext.c
+++ b/gettext.c
@@ -1,11 +1,13 @@
 #include "exec_cmd.h"
 #include <locale.h>
 #include <libintl.h>
+#include <langinfo.h>
 #include <stdlib.h>
 
 extern void git_setup_gettext(void) {
 	char *podir;
 	char *envdir = getenv("GIT_TEXTDOMAINDIR");
+	char *charset;
 
 	if (envdir) {
 		(void)bindtextdomain("git", envdir);
@@ -17,5 +19,9 @@ extern void git_setup_gettext(void) {
 	}
 
 	(void)setlocale(LC_MESSAGES, "");
+	(void)setlocale(LC_CTYPE, "");
+	charset = nl_langinfo(CODESET);
+	(void)bind_textdomain_codeset("git", charset);
+	(void)setlocale(LC_CTYPE, "C");
 	(void)textdomain("git");
 }
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 14/17] po/is.po: msgmerge and add Language: header

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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(-)
diff --git a/po/is.po b/po/is.po
index dfa3804..3bbfb97 100644
--- a/po/is.po
+++ b/po/is.po
@@ -1,10 +1,12 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: Git\n"
-"PO-Revision-Date: 2010-06-05 19:06 +0000\n"
-"Language-Team: Git Mailing List <git@vger.kernel.org>\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
+"POT-Creation-Date: 2010-08-28 17:38+0000\n"
+"PO-Revision-Date: 2010-08-28 17:27+0000\n"
 "Last-Translator: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n"
+"Language-Team: Git Mailing List <git@vger.kernel.org>\n"
+"Language: is\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 04/17] builtin.h: Include gettext.h

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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(-)
diff --git a/builtin.h b/builtin.h
index ed6ee26..6cd3bd8 100644
--- a/builtin.h
+++ b/builtin.h
@@ -6,6 +6,7 @@
 #include "cache.h"
 #include "commit.h"
 #include "notes.h"
+#include "gettext.h"
 
 extern const char git_version_string[];
 extern const char git_usage_string[];
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 12/17] gettext tests: test re-encoding with a UTF-8 msgid under Shell

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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(-)
diff --git a/po/is.po b/po/is.po
index 39b63b9..dfa3804 100644
--- a/po/is.po
+++ b/po/is.po
@@ -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:8
 msgid "TEST: A Shell test string"
 msgstr "TILRAUN: Skeljartilraunastrengur"
diff --git a/t/t0200/test.c b/t/t0200/test.c
index 82682dc..ff15c2f 100644
--- a/t/t0200/test.c
+++ b/t/t0200/test.c
@@ -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"));
 }
diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh
index 3222e37..1a7ea37 100755
--- a/t/t0204-gettext-reencode-sanity.sh
+++ b/t/t0204-gettext-reencode-sanity.sh
@@ -40,4 +40,25 @@ test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UT
 	fi
 '
 
+test_expect_success GETTEXT_LOCALE 'gettext: Fetching a UTF-8 msgid -> UTF-8' '
+    printf "TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir" >expect &&
+    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: ‘single’ and “double” quotes" >actual &&
+    test_cmp expect actual
+'
+
+# 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_success GETTEXT_ISO_LOCALE 'gettext: Fetching a UTF-8 msgid -> ISO-8859-1' '
+    LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: ‘single’ and “double” quotes" >actual &&
+    grep "einfaldar" actual &&
+    grep "$(echo tvöfaldar | iconv -f UTF-8 -t ISO8859-1)" actual
+'
+
 test_done
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 16/17] po/pl.po: add Polish translation

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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
diff --git a/po/pl.po b/po/pl.po
new file mode 100644
index 0000000..dfdd416
--- /dev/null
+++ b/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 ""
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 15/17] po/is.po: add Icelandic translation

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

Translate the non-TEST messages added in recent patches against
init-db.c. This brings Icelandic translation coverage up to 100%.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 po/is.po |  135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 127 insertions(+), 8 deletions(-)
diff --git a/po/is.po b/po/is.po
index 3bbfb97..5a35f0a 100644
--- a/po/is.po
+++ b/po/is.po
@@ -2,8 +2,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Git\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2010-08-28 17:38+0000\n"
-"PO-Revision-Date: 2010-08-28 17:27+0000\n"
+"POT-Creation-Date: 2010-08-30 18:16+0000\n"
+"PO-Revision-Date: 2010-08-28 19:25+0000\n"
 "Last-Translator: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n"
 "Language-Team: Git Mailing List <git@vger.kernel.org>\n"
 "Language: is\n"
@@ -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:5
 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
+#: t/t0200/test.c:10
 msgid "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-format
 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
+#: t/t0200/test.c:16
 #, 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
+#: t/t0200/test.c:19
 #, c-format
 msgid "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-format
 msgid "TEST: ‘single’ and “double” quotes"
 msgstr "TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir"
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 02/17] Makefile: provide a --msgid-bugs-address to xgettext(1)

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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(-)
diff --git a/Makefile b/Makefile
index 6a5bcf5..4b46579 100644
--- a/Makefile
+++ b/Makefile
@@ -2008,7 +2008,7 @@ cscope:
 	$(RM) cscope*
 	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 
-XGETTEXT_OPTIONS = --add-comments
+XGETTEXT_OPTIONS = --add-comments --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>"
 pot:
 	$(XGETTEXT) $(XGETTEXT_OPTIONS) --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
 	$(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 11/17] gettext tests: test message re-encoding under Shell

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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
diff --git a/po/is.po b/po/is.po
index 2f3a220..39b63b9 100644
--- a/po/is.po
+++ b/po/is.po
@@ -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:8
 msgid "TEST: A Shell test string"
 msgstr "TILRAUN: Skeljartilraunastrengur"
diff --git a/t/t0200/test.c b/t/t0200/test.c
index 93373b3..82682dc 100644
--- a/t/t0200/test.c
+++ b/t/t0200/test.c
@@ -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"));
 }
diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh
new file mode 100755
index 0000000..3222e37
--- /dev/null
+++ b/t/t0204-gettext-reencode-sanity.sh
@@ -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_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Icelandic' '
+    printf "TILRAUN: Halló Heimur!" >expect &&
+    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Hello World!" >actual &&
+    test_cmp expect actual
+'
+
+test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes' '
+    printf "TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ" >expect &&
+    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Old English Runes" >actual &&
+    test_cmp expect actual
+'
+
+test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Icelandic' '
+    printf "TILRAUN: Halló Heimur!" | iconv -f UTF-8 -t ISO8859-1 >expect &&
+    LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Hello World!" >actual &&
+    test_cmp expect actual
+'
+
+test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Runes' '
+    LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Old English Runes" >runes &&
+
+	if grep "^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_cmp runes-expect runes
+	fi
+'
+
+test_done
-- 
1.7.2.2.536.g3f548

[PATCH/RFC 09/17] gettext tests: update test/is.po to match t/t0200/test.c

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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(-)
diff --git a/po/is.po b/po/is.po
index 95739f1..2f3a220 100644
--- a/po/is.po
+++ b/po/is.po
@@ -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
diff --git a/t/t0200-gettext-basic.sh b/t/t0200-gettext-basic.sh
index 522338d..3846ea8 100755
--- a/t/t0200-gettext-basic.sh
+++ b/t/t0200-gettext-basic.sh
@@ -66,10 +66,10 @@ test_expect_success GETTEXT_LOCALE 'sanity: gettext(unknown) is passed through'
 test_expect_success GETTEXT_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=is LC_ALL="$is_IS_locale" gettext "TEST: A C test string" >actual &&
     printf "\n" >>actual &&
-    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "See git help COMMAND for more information on a specific command." >>actual &&
+    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "See '\''git help COMMAND'\'' for more information on a specific command." >>actual &&
     test_cmp expect actual
 '
 
-- 
1.7.2.2.536.g3f548

Re: [PATCH/RFC 00/17] Begin gettextizing Git

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/

Re: [PATCH/RFC 00/17] Begin gettextizing Git

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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

Re: [PATCH/RFC 00/17] Begin gettextizing Git

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.
Preferably with an active translation community.
Translation Project is indeed very active.
http://kerneltrap.org/mailarchive/git/2008/3/14/1163164 Is that the
one you're talking about?
Yes.
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/

Re: [PATCH/RFC 01/17] Makefile: A variable for options used by xgettext(1) calls

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:25

Ævar Arnfjörð Bjarmason wrote:
quoted hunk
+++ b/Makefile
@@ -2008,10 +2008,11 @@ cscope:
 	$(RM) cscope*
 	$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
 
+XGETTEXT_OPTIONS = --add-comments
 pot:
-	$(XGETTEXT) --add-comments --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
-	$(XGETTEXT) --add-comments --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
-	$(XGETTEXT) --add-comments --join-existing --keyword=__ --output=po/git.pot --language=Perl $(SCRIPT_PERL) t/t0200/test.perl
+	$(XGETTEXT) $(XGETTEXT_OPTIONS) --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
+	$(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
+	$(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --keyword=__ --output=po/git.pot --language=Perl $(SCRIPT_PERL) t/t0200/test.perl
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 $@+ $@

Re: [PATCH/RFC 05/17] gettext: make the simple parts of git-init localizable

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)
 		}
 	}
 	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?).

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.)

Re: [PATCH/RFC 06/17] gettext: localize the main git-init message

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.)

Re: [PATCH/RFC 07/17] gettext.c: work around us not using setlocale(LC_CTYPE, "")

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?
quoted hunk
--- a/gettext.c
+++ b/gettext.c
@@ -17,5 +19,9 @@ extern void git_setup_gettext(void) {
 	}
 
 	(void)setlocale(LC_MESSAGES, "");
+	(void)setlocale(LC_CTYPE, "");
+	charset = nl_langinfo(CODESET);
+	(void)bind_textdomain_codeset("git", charset);
+	(void)setlocale(LC_CTYPE, "C");
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.

Re: [PATCH/RFC 15/17] po/is.po: add Icelandic translation

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:25

Ævar Arnfjörð Bjarmason wrote:
quoted hunk
--- a/po/is.po
+++ b/po/is.po
@@ -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
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).

Re: [PATCH/RFC 00/17] Begin gettextizing Git

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:25

Ævar Arnfjörð Bjarmason wrote:
Now that Git has the infrastructure for translation in next I'm going
to start submitting patches to make the main porcelain translatable.
I've written some comments on specific patches; the rest looks good
to me.

Thanks for moving this forward.

Re: [PATCH/RFC 05/17] gettext: make the simple parts of git-init localizable

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

On Tue, Aug 31, 2010 at 15:03, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -31,7 +31,7 @@ static void safe_create_dir(const char *dir, int share)
              }
      }
      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.

Re: [PATCH/RFC 07/17] gettext.c: work around us not using setlocale(LC_CTYPE, "")

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

Re: [PATCH/RFC 06/17] gettext: localize the main git-init message

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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.

Re: [PATCH/RFC 05/17] gettext: make the simple parts of git-init localizable

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

Re: [PATCH/RFC 06/17] gettext: localize the main git-init message

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.

Re: [PATCH/RFC 07/17] gettext.c: work around us not using setlocale(LC_CTYPE, "")

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.
[...]
Solaris 9 has it, too.
Thanks for checking.  That's good to hear.

Re: [PATCH/RFC 05/17] gettext: make the simple parts of git-init localizable

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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.

Re: [PATCH/RFC 00/17] Begin gettextizing Git

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

On Tue, Aug 31, 2010 at 15:32, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
Now that Git has the infrastructure for translation in next I'm going
to start submitting patches to make the main porcelain translatable.
I've written some comments on specific patches; the rest looks good
to me.
I'll try to reply to them all.
Thanks for moving this forward.
And thanks for your continuing efforts in reviewing all of this.

Re: [PATCH/RFC 05/17] gettext: make the simple parts of git-init localizable

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:25

Ævar Arnfjörð Bjarmason wrote:
On Tue, Aug 31, 2010 at 15:44, Jonathan Nieder [off-list ref] wrote:
quoted
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");
Same result, alas.

Re: [PATCH/RFC 01/17] Makefile: A variable for options used by xgettext(1) calls

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

On Tue, Aug 31, 2010 at 14:51, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
+++ b/Makefile
@@ -2008,10 +2008,11 @@ cscope:
      $(RM) cscope*
      $(FIND) . -name '*.[hcS]' -print | xargs cscope -b

+XGETTEXT_OPTIONS = --add-comments
 pot:
-     $(XGETTEXT) --add-comments --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
-     $(XGETTEXT) --add-comments --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
-     $(XGETTEXT) --add-comments --join-existing --keyword=__ --output=po/git.pot --language=Perl $(SCRIPT_PERL) t/t0200/test.perl
+     $(XGETTEXT) $(XGETTEXT_OPTIONS) --keyword=_ --keyword=N_ --output=po/git.pot --language=C $(C_OBJ:o=c) t/t0200/test.c
+     $(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --output=po/git.pot --language=Shell $(SCRIPT_SH) t/t0200/test.sh
+     $(XGETTEXT) $(XGETTEXT_OPTIONS) --join-existing --keyword=__ --output=po/git.pot --language=Perl $(SCRIPT_PERL) t/t0200/test.perl
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 $@+ $@
Thanks. I worked that into v2.

Re: [PATCH/RFC 07/17] gettext.c: work around us not using setlocale(LC_CTYPE, "")

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

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?
quoted
--- a/gettext.c
+++ b/gettext.c
@@ -17,5 +19,9 @@ extern void git_setup_gettext(void) {
      }

      (void)setlocale(LC_MESSAGES, "");
+     (void)setlocale(LC_CTYPE, "");
+     charset = nl_langinfo(CODESET);
+     (void)bind_textdomain_codeset("git", charset);
+     (void)setlocale(LC_CTYPE, "C");
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.

Re: [PATCH/RFC 15/17] po/is.po: add Icelandic translation

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

On Tue, Aug 31, 2010 at 15:29, Jonathan Nieder [off-list ref] wrote:
Ævar Arnfjörð Bjarmason wrote:
quoted
--- a/po/is.po
+++ b/po/is.po
@@ -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
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 :)

Re: [PATCH/RFC 15/17] po/is.po: add Icelandic translation

From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:49:25

On Tue, Aug 31, 2010 at 7:01 PM, Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
On Tue, Aug 31, 2010 at 15:29, Jonathan Nieder [off-list ref] wrote:
quoted
Ævar Arnfjörð Bjarmason wrote:
quoted
--- a/po/is.po
+++ b/po/is.po
@@ -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
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
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.

Re: [PATCH/RFC 15/17] po/is.po: add Icelandic translation

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:25

On Tue, Aug 31, 2010 at 19:14, Erik Faye-Lund [off-list ref] wrote:
On Tue, Aug 31, 2010 at 7:01 PM, Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
quoted
On Tue, Aug 31, 2010 at 15:29, Jonathan Nieder [off-list ref] wrote:
quoted
Ævar Arnfjörð Bjarmason wrote:
quoted
--- a/po/is.po
+++ b/po/is.po
@@ -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
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
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.

Re: [PATCH/RFC 15/17] po/is.po: add Icelandic translation

From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:49:25

On Tue, Aug 31, 2010 at 9:32 PM, Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
On Tue, Aug 31, 2010 at 19:14, Erik Faye-Lund [off-list ref] wrote:
quoted
On Tue, Aug 31, 2010 at 7:01 PM, Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
quoted
On Tue, Aug 31, 2010 at 15:29, Jonathan Nieder [off-list ref] wrote:
quoted
Ævar Arnfjörð Bjarmason wrote:
quoted
--- a/po/is.po
+++ b/po/is.po
@@ -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
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
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.

Re: [PATCH/RFC 07/17] gettext.c: work around us not using setlocale(LC_CTYPE, "")

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?
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.

[1] http://www.opengroup.org/onlinepubs/9699919799/functions/printf.html#tag_16_159_03
[2] http://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libc/stdio/vfprintf.c?cvsroot=src

Re: [PATCH/RFC 07/17] gettext.c: work around us not using setlocale(LC_CTYPE, "")

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help