v1.18.x
Barış Soner Uşaklı 7 years ago
parent be00a1c013
commit c12b42180d

@ -137,16 +137,16 @@ define('notifications', ['sounds', 'translator', 'components', 'navigator', 'ben
return parseInt(a.datetime, 10) > parseInt(b.datetime, 10) ? -1 : 1; return parseInt(a.datetime, 10) > parseInt(b.datetime, 10) ? -1 : 1;
}); });
translator.toggleTimeagoShorthand(); translator.toggleTimeagoShorthand(function () {
for (var i = 0; i < notifs.length; i += 1) { for (var i = 0; i < notifs.length; i += 1) {
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10))); notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
} }
translator.toggleTimeagoShorthand(); translator.toggleTimeagoShorthand();
Benchpress.parse('partials/notifications_list', { notifications: notifs }, function (html) { Benchpress.parse('partials/notifications_list', { notifications: notifs }, function (html) {
notifList.translateHtml(html); notifList.translateHtml(html);
}); });
}); });
});
}; };
Notifications.updateNotifCount = function (count) { Notifications.updateNotifCount = function (count) {

@ -576,23 +576,29 @@
adaptor.getTranslations(language, namespace, callback); adaptor.getTranslations(language, namespace, callback);
}, },
toggleTimeagoShorthand: function toggleTimeagoShorthand() { toggleTimeagoShorthand: function toggleTimeagoShorthand(callback) {
function toggle() {
var tmp = assign({}, jQuery.timeago.settings.strings); var tmp = assign({}, jQuery.timeago.settings.strings);
jQuery.timeago.settings.strings = assign({}, adaptor.timeagoShort); jQuery.timeago.settings.strings = assign({}, adaptor.timeagoShort);
adaptor.timeagoShort = assign({}, tmp); adaptor.timeagoShort = assign({}, tmp);
}, if (typeof callback === 'function') {
prepareDOM: function prepareDOM() { callback();
// Load the appropriate timeago locale file, }
// and correct NodeBB language codes to timeago codes, if necessary }
var languageCode = utils.userLangToTimeagoCode(config.userLang);
adaptor.timeagoShort = assign({}, jQuery.timeago.settings.strings);
if (!adaptor.timeagoShort) {
var languageCode = utils.userLangToTimeagoCode(config.userLang);
var originalSettings = assign({}, jQuery.timeago.settings.strings);
jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '-short.js').done(function () { jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '-short.js').done(function () {
// Switch back to long-form adaptor.timeagoShort = assign({}, jQuery.timeago.settings.strings);
adaptor.toggleTimeagoShorthand(); jQuery.timeago.settings.strings = assign({}, originalSettings);
toggle();
}); });
} else {
toggle();
}
},
prepareDOM: function prepareDOM() {
// Add directional code if necessary // Add directional code if necessary
adaptor.translate('[[language:dir]]', function (value) { adaptor.translate('[[language:dir]]', function (value) {
if (value && !$('html').attr('data-dir')) { if (value && !$('html').attr('data-dir')) {

Loading…
Cancel
Save