After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 738640 - Use LC_TIME locale for strftime format string translations
Use LC_TIME locale for strftime format string translations
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
: 748284 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-10-16 15:19 UTC by Florian Müllner
Modified: 2015-04-22 10:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use LC_TIME locale for strftime format string translations (9.85 KB, patch)
2014-10-16 15:19 UTC, Florian Müllner
needs-work Details | Review
Use LC_TIME locale for strftime format string translations (9.85 KB, patch)
2014-10-16 17:12 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2014-10-16 15:19:46 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.
Comment 1 Florian Müllner 2014-10-16 15:19:50 UTC
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.
Comment 2 Jasper St. Pierre (not reading bugmail) 2014-10-16 17:03:57 UTC
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);
Comment 3 Florian Müllner 2014-10-16 17:08:29 UTC
(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.
Comment 4 Florian Müllner 2014-10-16 17:12:37 UTC
Created attachment 288702 [details] [review]
Use LC_TIME locale for strftime format string translations

Only reset LC_MESSAGES.
Comment 5 Jasper St. Pierre (not reading bugmail) 2014-10-16 17:32:03 UTC
Review of attachment 288702 [details] [review]:

Ah, OK, I wasn't aware. Still seems a bit bizarre of an API, but OK.
Comment 6 Florian Müllner 2014-10-16 21:44:23 UTC
Attachment 288702 [details] pushed as eb3fc78 - Use LC_TIME locale for strftime format string translations
Comment 7 Florian Müllner 2015-04-22 10:38:16 UTC
*** Bug 748284 has been marked as a duplicate of this bug. ***