mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: #7824, update timeago settings on userlanguage change
This commit is contained in:
@@ -81,11 +81,11 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
}
|
||||
|
||||
app.alertSuccess('[[success:settings-saved]]');
|
||||
var requireReload = false;
|
||||
var languageChanged = false;
|
||||
for (var key in newSettings) {
|
||||
if (newSettings.hasOwnProperty(key)) {
|
||||
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
|
||||
requireReload = true;
|
||||
languageChanged = true;
|
||||
}
|
||||
if (config.hasOwnProperty(key)) {
|
||||
config[key] = newSettings[key];
|
||||
@@ -95,13 +95,16 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
|
||||
sounds.loadMap();
|
||||
|
||||
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
||||
if (languageChanged && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
||||
translator.translate('[[language:dir]]', config.userLang, function (translated) {
|
||||
var htmlEl = $('html');
|
||||
htmlEl.attr('data-dir', translated);
|
||||
htmlEl.css('direction', translated);
|
||||
});
|
||||
ajaxify.refresh();
|
||||
$.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + utils.userLangToTimeagoCode(config.userLang) + '.js', function () {
|
||||
overrides.overrideTimeago();
|
||||
ajaxify.refresh();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,9 +108,12 @@ if (typeof window !== 'undefined') {
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
var timeagoFn;
|
||||
overrides.overrideTimeago = function () {
|
||||
var timeagoFn = $.fn.timeago;
|
||||
if (!timeagoFn) {
|
||||
timeagoFn = $.fn.timeago;
|
||||
}
|
||||
|
||||
if (parseInt(config.timeagoCutoff, 10) === 0) {
|
||||
$.timeago.settings.cutoff = 1;
|
||||
} else if (parseInt(config.timeagoCutoff, 10) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user