mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 17:46:16 +01:00
fix: #7289 timeago shorthand toggle fails on non-existant language
- Exposing timeagoCodes to frontend - Timeago language and shorthand toggling will fall back to 'en' if the requested language does not exist
This commit is contained in:
@@ -586,6 +586,10 @@
|
||||
|
||||
if (!adaptor.timeagoShort) {
|
||||
var languageCode = utils.userLangToTimeagoCode(config.userLang);
|
||||
if (!config.timeagoCodes.includes(languageCode + '-short')) {
|
||||
languageCode = 'en';
|
||||
}
|
||||
|
||||
var originalSettings = assign({}, jQuery.timeago.settings.strings);
|
||||
jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '-short.js').done(function () {
|
||||
adaptor.timeagoShort = assign({}, jQuery.timeago.settings.strings);
|
||||
@@ -602,6 +606,9 @@
|
||||
delete adaptor.timeagoShort;
|
||||
|
||||
var languageCode = utils.userLangToTimeagoCode(config.userLang);
|
||||
if (!config.timeagoCodes.includes(languageCode + '-short')) {
|
||||
languageCode = 'en';
|
||||
}
|
||||
jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '.js').done(callback);
|
||||
},
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ var categories = require('../categories');
|
||||
var privileges = require('../privileges');
|
||||
var plugins = require('../plugins');
|
||||
var translator = require('../translator');
|
||||
var languages = require('../languages');
|
||||
|
||||
var apiController = module.exports;
|
||||
|
||||
@@ -62,6 +63,7 @@ apiController.loadConfig = function (req, callback) {
|
||||
config.bootswatchSkin = meta.config.bootswatchSkin || '';
|
||||
config.enablePostHistory = (meta.config.enablePostHistory || 1) === 1;
|
||||
config.notificationAlertTimeout = meta.config.notificationAlertTimeout || 5000;
|
||||
config.timeagoCodes = languages.timeagoCodes;
|
||||
|
||||
if (config.useOutgoingLinksPage) {
|
||||
config.outgoingLinksWhitelist = meta.config['outgoingLinks:whitelist'];
|
||||
|
||||
Reference in New Issue
Block a user