Do not rely on locale from context as fallback format for date
Since 6c5f4d760e54, the locale key is removed from the RPC context so the fallback for the date format must come from the translation utilities. Closes #13290
This commit is contained in:
1 parent
8f49454f08
commit
e45ff0098b
3 files changed
+9
-13
No files matched your search
+2
-10
@@ -228,16 +228,8 @@
|
||||
];
|
||||
|
||||
Sao.common.date_format = function(format) {
|
||||
if (jQuery.isEmptyObject(format)) {
|
||||
format = '%x';
|
||||
if (Sao.Session.current_session) {
|
||||
var context = Sao.Session.current_session.context;
|
||||
if (context.locale && context.locale.date) {
|
||||
format = context.locale.date;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Sao.common.moment_format(format);
|
||||
return Sao.common.moment_format(
|
||||
format || Sao.i18n.locale.date || '%x');
|
||||
};
|
||||
|
||||
Sao.common.format_time = function(format, date) {
|
||||
|
||||
@@ -37,6 +37,7 @@ from string import Template
|
||||
from threading import Lock, Thread
|
||||
|
||||
import tryton.rpc as rpc
|
||||
import tryton.translate as translate
|
||||
from tryton.cache import CacheDict
|
||||
from tryton.config import CONFIG, PIXMAPS_DIR, SOUNDS_DIR, TRYTON_ICON
|
||||
|
||||
@@ -1528,7 +1529,7 @@ def get_align(float_, expand=True):
|
||||
|
||||
|
||||
def date_format(format_=None):
|
||||
return format_ or rpc.CONTEXT.get('locale', {}).get('date', '%x')
|
||||
return format_ or translate.DATE or '%x'
|
||||
|
||||
|
||||
def idle_add(func):
|
||||
|
||||
@@ -12,6 +12,7 @@ from gi.repository import Gtk
|
||||
from tryton.config import CURRENT_DIR
|
||||
|
||||
_ = gettext.gettext
|
||||
DATE = None
|
||||
|
||||
_LOCALE2WIN32 = {
|
||||
'af_ZA': 'Afrikaans_South Africa',
|
||||
@@ -196,8 +197,10 @@ def setlang(lang=None, locale_dict=None):
|
||||
conv = locale.localeconv()
|
||||
for field in list(locale_dict.keys()):
|
||||
if field == 'date':
|
||||
continue
|
||||
conv[field] = locale_dict[field]
|
||||
global DATE
|
||||
DATE = locale_dict[field]
|
||||
else:
|
||||
conv[field] = locale_dict[field]
|
||||
locale.localeconv = lambda: conv
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user