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.

https://bugzilla.gnome.org/show_bug.cgi?id=738640
This commit is contained in:
Florian Müllner
2014-10-16 14:38:13 +02:00
parent 2f5a226bc2
commit eb3fc7815e
6 changed files with 51 additions and 16 deletions

View File

@ -85,7 +85,8 @@ const Clock = new Lang.Class({
let date = new Date();
/* Translators: This is a time format for a date in
long format */
this._date.text = date.toLocaleFormat(_("%A, %B %d"));
let dateFormat = Shell.util_translate_time_string("%A, %B %d");
this._date.text = date.toLocaleFormat(dateFormat);
},
destroy: function() {