Thread (21 messages) flat view 21 messages, 5 authors, 2016-06-15

Re: [PATCH 04/10] i18n: help: mark strings for translation

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:53:39

Nguyễn Thái Ngọc Duy wrote:
quoted hunk ↗ jump to hunk
--- a/help.c
+++ b/help.c
@@ -217,8 +217,9 @@ void list_commands(const char *title, struct cmdnames *main_cmds,
 
 	if (main_cmds->cnt) {
 		const char *exec_path = git_exec_path();
-		printf("available %s in '%s'\n", title, exec_path);
-		printf("----------------");
+		printf_ln(_("available %s in '%s'"), title, exec_path);
+		/* TRANSLATORS: this must align with "available %s in '%s'" */
+		printf(_("----------------"));
 		mput_char('-', strlen(title) + strlen(exec_path));
Yuck. :)

I would be tempted to do:

	static int strbuf_utf8_width(const struct strbuf *sb)
	{
		char char *p = sb->buf;
		size_t remainder = sb->len;
		int width;

		width = utf8_width(&p, &remainder);
		if (!p || remainder)
			return sb->len;
		return width;
	}
	...

		struct strbuf sb = STRBUF_INIT;
		const char *p;

		strbuf_addf(&sb, _("available %s in '%s'"), title, exec_path);
		fwrite(sb.buf, sb.len, 1, stdout);
		putchar('\n');

		/* NEEDSWORK: handle non-UTF8 locales? */
		mput_char('-', strbuf_utf8_width(&sb));

		strbuf_release(&sb);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help