mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: timeago locale switch
This commit is contained in:
@@ -92,10 +92,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
|||||||
htmlEl.css('direction', translated);
|
htmlEl.css('direction', translated);
|
||||||
});
|
});
|
||||||
|
|
||||||
var stringsModule = 'timeago/locales/jquery.timeago.' + utils.userLangToTimeagoCode(config.userLang);
|
translator.switchTimeagoLanguage(utils.userLangToTimeagoCode(config.userLang), function () {
|
||||||
// without undef, requirejs won't load the strings a second time
|
|
||||||
require.undef(stringsModule);
|
|
||||||
require([stringsModule], function () {
|
|
||||||
overrides.overrideTimeago();
|
overrides.overrideTimeago();
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -605,7 +605,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var originalSettings = assign({}, jQuery.timeago.settings.strings);
|
var originalSettings = assign({}, jQuery.timeago.settings.strings);
|
||||||
jQuery.getScript(config.assetBaseUrl + '/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '-short.js').done(function () {
|
adaptor.switchTimeagoLanguage(languageCode + '-short', function () {
|
||||||
adaptor.timeagoShort = assign({}, jQuery.timeago.settings.strings);
|
adaptor.timeagoShort = assign({}, jQuery.timeago.settings.strings);
|
||||||
jQuery.timeago.settings.strings = assign({}, originalSettings);
|
jQuery.timeago.settings.strings = assign({}, originalSettings);
|
||||||
toggle();
|
toggle();
|
||||||
@@ -615,12 +615,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
switchTimeagoLanguage: function switchTimeagoLanguage(callback) {
|
switchTimeagoLanguage: function switchTimeagoLanguage(langCode, callback) {
|
||||||
// Delete the cached shorthand strings if present
|
// Delete the cached shorthand strings if present
|
||||||
delete adaptor.timeagoShort;
|
delete adaptor.timeagoShort;
|
||||||
|
|
||||||
var languageCode = utils.userLangToTimeagoCode(config.userLang);
|
var stringsModule = 'timeago/locales/jquery.timeago.' + langCode;
|
||||||
jQuery.getScript(config.assetBaseUrl + '/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '.js').done(callback);
|
// without undef, requirejs won't load the strings a second time
|
||||||
|
require.undef(stringsModule);
|
||||||
|
require([stringsModule], function () {
|
||||||
|
callback();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
prepareDOM: function prepareDOM() {
|
prepareDOM: function prepareDOM() {
|
||||||
|
|||||||
Reference in New Issue
Block a user