mirror of
https://github.com/plankanban/planka.git
synced 2025-12-22 17:25:01 +03:00
fix: Create isolated i18n instances to prevent locale collision
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const I18n = require('i18n-2');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sync: true,
|
sync: true,
|
||||||
|
|
||||||
@@ -14,9 +17,21 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fn(inputs) {
|
fn(inputs) {
|
||||||
const i18n = _.cloneDeep(sails.hooks.i18n);
|
const i18n = new I18n({
|
||||||
|
locales: sails.config.i18n.locales,
|
||||||
|
defaultLocale: sails.config.i18n.defaultLocale,
|
||||||
|
directory: path.join(sails.config.appPath, sails.config.i18n.localesDirectory),
|
||||||
|
extension: '.json',
|
||||||
|
devMode: false,
|
||||||
|
});
|
||||||
|
|
||||||
i18n.setLocale(inputs.language || sails.config.i18n.defaultLocale);
|
i18n.setLocale(inputs.language || sails.config.i18n.defaultLocale);
|
||||||
|
|
||||||
return i18n.__.bind(i18n); // eslint-disable-line no-underscore-dangle
|
/* eslint-disable no-underscore-dangle */
|
||||||
|
const translator = i18n.__.bind(i18n);
|
||||||
|
translator.n = i18n.__n.bind(i18n);
|
||||||
|
/* eslint-enable no-underscore-dangle */
|
||||||
|
|
||||||
|
return translator;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
1
server/package-lock.json
generated
1
server/package-lock.json
generated
@@ -16,6 +16,7 @@
|
|||||||
"escape-html": "^1.0.3",
|
"escape-html": "^1.0.3",
|
||||||
"escape-markdown": "^1.0.4",
|
"escape-markdown": "^1.0.4",
|
||||||
"fs-extra": "^11.3.2",
|
"fs-extra": "^11.3.2",
|
||||||
|
"i18n-2": "^0.7.3",
|
||||||
"ico-to-png": "^0.2.2",
|
"ico-to-png": "^0.2.2",
|
||||||
"istextorbinary": "^9.5.0",
|
"istextorbinary": "^9.5.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
"escape-html": "^1.0.3",
|
"escape-html": "^1.0.3",
|
||||||
"escape-markdown": "^1.0.4",
|
"escape-markdown": "^1.0.4",
|
||||||
"fs-extra": "^11.3.2",
|
"fs-extra": "^11.3.2",
|
||||||
|
"i18n-2": "^0.7.3",
|
||||||
"ico-to-png": "^0.2.2",
|
"ico-to-png": "^0.2.2",
|
||||||
"istextorbinary": "^9.5.0",
|
"istextorbinary": "^9.5.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user