mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-14 17:56:16 +01:00
partial revert of a9984bb, adding in a layer to translate ISO
timestamp to datetime attribute and save localised string into title attribute. Fixes #5109
This commit is contained in:
@@ -152,13 +152,18 @@ if ('undefined' !== typeof window) {
|
|||||||
var timeagoFn = $.fn.timeago;
|
var timeagoFn = $.fn.timeago;
|
||||||
$.timeago.settings.cutoff = 1000 * 60 * 60 * 24 * 30;
|
$.timeago.settings.cutoff = 1000 * 60 * 60 * 24 * 30;
|
||||||
$.fn.timeago = function () {
|
$.fn.timeago = function () {
|
||||||
var els = timeagoFn.apply(this, arguments);
|
var els = $(this);
|
||||||
|
|
||||||
if (els) {
|
// Convert "old" format to new format (#5108)
|
||||||
els.each(function () {
|
var options = { year: 'numeric', month: 'long', day: 'numeric' };
|
||||||
$(this).attr('title', (new Date($(this).attr('title'))).toString());
|
var iso;
|
||||||
});
|
els.each(function() {
|
||||||
}
|
iso = this.getAttribute('title');
|
||||||
|
this.setAttribute('datetime', iso);
|
||||||
|
this.setAttribute('title', new Date(iso).toLocaleString(config.userLang.replace('_', '-'), options));
|
||||||
|
});
|
||||||
|
|
||||||
|
timeagoFn.apply(this, arguments);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
36
public/vendor/jquery/timeago/jquery.timeago.js
vendored
36
public/vendor/jquery/timeago/jquery.timeago.js
vendored
@@ -194,41 +194,7 @@
|
|||||||
$(this).text(inWords(data.datetime));
|
$(this).text(inWords(data.datetime));
|
||||||
} else {
|
} else {
|
||||||
if ($(this).attr('title').length > 0) {
|
if ($(this).attr('title').length > 0) {
|
||||||
//$(this).text($(this).attr('title'));
|
$(this).text($(this).attr('title'));
|
||||||
var languageCode = void 0;
|
|
||||||
switch (config.userLang) {
|
|
||||||
case 'en_GB':
|
|
||||||
case 'en_US':
|
|
||||||
languageCode = 'en';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'fa_IR':
|
|
||||||
languageCode = 'fa';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'pt_BR':
|
|
||||||
languageCode = 'pt-br';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'nb':
|
|
||||||
languageCode = 'no';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'zh_TW':
|
|
||||||
languageCode = 'zh-TW';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'zh_CN':
|
|
||||||
languageCode = 'zh-CN';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
languageCode = config.userLang;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = { year: 'numeric', month: 'long', day: 'numeric' };
|
|
||||||
$(this).text(new Date($(this).attr('title')).toLocaleString(languageCode, options));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user