Refactor translation method
This commit is contained in:
parent
1c663b7675
commit
172e06ed3f
1 changed files with 14 additions and 10 deletions
|
@ -187,18 +187,22 @@ import * as userSettings from './settings/userSettings';
|
|||
|
||||
function translateKeyFromModule(key, module) {
|
||||
let dictionary = getDictionary(module, getCurrentLocale());
|
||||
if (!dictionary || !dictionary[key]) {
|
||||
dictionary = getDictionary(module, fallbackCulture);
|
||||
if (dictionary && dictionary[key]) {
|
||||
return dictionary[key];
|
||||
}
|
||||
if (!dictionary || !dictionary[key]) {
|
||||
if (dictionary && isEmpty(dictionary)) {
|
||||
console.warn('Translation dictionary is empty.');
|
||||
} else {
|
||||
console.error(`Translation key is missing from dictionary: ${key}`);
|
||||
}
|
||||
return key;
|
||||
|
||||
dictionary = getDictionary(module, fallbackCulture);
|
||||
if (dictionary && dictionary[key]) {
|
||||
return dictionary[key];
|
||||
}
|
||||
return dictionary[key];
|
||||
|
||||
if (!dictionary || isEmpty(dictionary)) {
|
||||
console.warn('Translation dictionary is empty.');
|
||||
} else {
|
||||
console.error(`Translation key is missing from dictionary: ${key}`);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
function replaceAll(str, find, replace) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue