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