Re: [PATCH v2 1/2] object.[ch]: mark object type names for translation

2 messages, 2 authors, 2021-10-06 · open the first message on its own page

Re: [PATCH v2 1/2] object.[ch]: mark object type names for translation

From: Junio C Hamano <hidden>
Date: 2021-10-06 19:46:19

Jeff King [off-list ref] writes:
They all appear to want is as a noun. So maybe this is just
mis-translated for Spanish. It does feel like an accident in the making,
though.
Probably we need pgettext().

https://www.gnu.org/software/gettext/manual/html_node/Contexts.html
I do wonder how useful it is to translate these type names in general.
Especially as used in this series, they're really technical terms, and
you are not going to escape the name "git commit" as a command.
I share the same feeling (I do not use translated git, either).
Now if you introduced type_name_human(), which auto-translated and
converted NULL to "unknown", then that would be easy to plug in
appropriately as you audited the callers.
Yes.
quoted
 static const char *object_type_strings[] = {
...
+	N_("commit"),	/* OBJ_COMMIT = 1 */
+	N_("tree"),	/* OBJ_TREE = 2 */
+	N_("blob"),	/* OBJ_BLOB = 3 */
+	N_("tag"),	/* OBJ_TAG = 4 */
 };
This does make me feel slightly uneasy, just because so many parts of
Git rely on these _not_ being translated. But I see in your other
response that N_() really does nothing. So aside from possibly
misleading readers of the code, I think this is probably OK.
Yes, this may be scary looking but the least risky part of this
patch, as N_() is no-op at runtime ;-).

Re: [PATCH v2 1/2] object.[ch]: mark object type names for translation

From: Jeff King <hidden>
Date: 2021-10-06 20:38:32

On Wed, Oct 06, 2021 at 12:46:12PM -0700, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
They all appear to want is as a noun. So maybe this is just
mis-translated for Spanish. It does feel like an accident in the making,
though.
Probably we need pgettext().

https://www.gnu.org/software/gettext/manual/html_node/Contexts.html
Yeah, that make sense. I'm not sure how it interacts with N_(), though.
I.e., I'd expect the "context" to ride along with the original string,
but I guess it is really in the caller who's translating it. So the real
spot becomes:

  printf(_("my type is %s"), pgettext("object-type", type_name(type)));

It's a little unfortunate that every caller has to do it rather than
putting it near the source string. But I guess a type_name_human() would
solve that, too. ;)

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help