Fix Localization Serialization
This commit is contained in:
+1
@@ -4,6 +4,7 @@ interface CssExports {
|
||||
'deleteButton': string;
|
||||
'hideMetadataProfile': string;
|
||||
'labelIcon': string;
|
||||
'message': string;
|
||||
}
|
||||
export const cssExports: CssExports;
|
||||
export default cssExports;
|
||||
|
||||
@@ -7,7 +7,7 @@ function getTranslations() {
|
||||
dataType: 'json',
|
||||
url: '/localization',
|
||||
success: function(data) {
|
||||
localization = data.Strings;
|
||||
localization = data.strings;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,12 +19,13 @@ function getTranslations() {
|
||||
const translations = getTranslations();
|
||||
|
||||
export default function translate(key, args = '') {
|
||||
const translation = translations[key] || key;
|
||||
|
||||
if (args) {
|
||||
const translatedKey = translate(key);
|
||||
return translatedKey.replace(/\{(\d+)\}/g, (match, index) => {
|
||||
return translation.replace(/\{(\d+)\}/g, (match, index) => {
|
||||
return args[index];
|
||||
});
|
||||
}
|
||||
|
||||
return translations[key] || key;
|
||||
return translation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user