Minor fix to plugin I18N mechanism

This commit is contained in:
Rainer Simon 2021-09-30 09:10:26 +02:00
parent ad26be479f
commit 70b960e7d6
3 changed files with 9 additions and 8 deletions

3
package-lock.json generated
View File

@ -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": {

View File

@ -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",

View File

@ -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;