Minor fix to plugin I18N mechanism
This commit is contained in:
parent
ad26be479f
commit
70b960e7d6
|
@ -26,6 +26,9 @@
|
||||||
"@babel/preset-env": "^7.6.2",
|
"@babel/preset-env": "^7.6.2",
|
||||||
"@babel/register": "^7.9.0",
|
"@babel/register": "^7.9.0",
|
||||||
"mocha": "^7.1.1"
|
"mocha": "^7.1.1"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/rsimon"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/code-frame": {
|
"node_modules/@babel/code-frame": {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
"url": "https://github.com/recogito/recogito-client-core/issues"
|
"url": "https://github.com/recogito/recogito-client-core/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/recogito/recogito-client-core/wiki",
|
"homepage": "https://github.com/recogito/recogito-client-core/wiki",
|
||||||
|
"funding": "https://github.com/sponsors/rsimon",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.6.2",
|
"@babel/core": "^7.6.2",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
||||||
|
|
|
@ -86,16 +86,13 @@ timeago.register('tr', tr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function that allows plugins to register their
|
* Helper function that allows plugins to register their
|
||||||
* own I18N labels
|
* own additional I18N labels
|
||||||
*/
|
*/
|
||||||
i18n.registerMessages = dict => {
|
i18n.registerMessages = (lang, messages) => {
|
||||||
const currentLocale = i18n.locale();
|
if (MESSAGES[lang])
|
||||||
const messages = dict[currentLocale];
|
MESSAGES[lang] = {...MESSAGES[lang], ...messages };
|
||||||
|
|
||||||
if (messages)
|
|
||||||
i18n.extend(messages);
|
|
||||||
else
|
else
|
||||||
console.warn(`Locale ${currentLocale} not supported by plugin widget - falling back to defaults`);
|
MESSAGES[lang] = messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
|
Loading…
Reference in New Issue