GNOME Bugzilla – Bug 738640
Use LC_TIME locale for strftime format string translations
Last modified: 2015-04-22 10:38:16 UTC
There is no perfect way of handling different LC_MESSAGES and LC_TIME locales, but from the options we have: (1) use format and translations (month/weekday names etc.) from LC_TIME (2) use format from LC_TIME and translations from LC_MESSAGES (3) use format from LC_MESSAGES and translations from LC_TIME (3) is the one that makes least sense (the translations don't match the language used anywhere else in the system, *and* the resulting date string does not make sense in either language). It also happens to be the one we are using :-) (2) is better in that translated strings match the language used elsewhere, but the result is still an ugly mix of locales ("Thursday, der 20. October"), so I prefer the first option.
Created attachment 288696 [details] [review] Use LC_TIME locale for strftime format string translations We commonly mark strftime format strings for translation to account for date/time representations without an existing strftime shortcut ("Yesterday %H%p"). As those translations are looked up according to the locale defined by LC_MESSAGES, while the conversion characters themselves are resolved according to LC_TIME, the result can be rather odd when mixing locales ("Den 27. January"). The correct solution would be to install translations for format strings in the LC_TIME catalogue and look them up with dcgettext(), but we don't have the infrastructure to do that easily. Work around this by adding a helper method that looks up a string in LC_MESSAGES using the locale defined by LC_TIME and use that to translate format strings, which has the same result.
Review of attachment 288696 [details] [review]: ::: src/shell-util.c @@ +231,3 @@ + res = gettext (str); + + setlocale (LC_ALL, ""); ... you just set LC_MESSAGES above, now you're resetting LC_ALL? To empty string? This should be: if (locale) oldlocale = setlocale (LC_MESSAGES, locale); else oldlocale = NULL; res = gettext (str); if (oldlocale) setlocale (LC_MESSAGES, oldlocale);
(In reply to comment #2) > ... you just set LC_MESSAGES above, now you're resetting LC_ALL? To empty > string? This means: set all categories according to the corresponding LC_FOO environment variable. Which is perfectly fine.
Created attachment 288702 [details] [review] Use LC_TIME locale for strftime format string translations Only reset LC_MESSAGES.
Review of attachment 288702 [details] [review]: Ah, OK, I wasn't aware. Still seems a bit bizarre of an API, but OK.
Attachment 288702 [details] pushed as eb3fc78 - Use LC_TIME locale for strftime format string translations
*** Bug 748284 has been marked as a duplicate of this bug. ***