Fix Localization Serialization

This commit is contained in:
Qstick
2023-05-29 23:34:55 -05:00
parent 9f1ec2a2c3
commit 937a8518ad
4 changed files with 34 additions and 12 deletions
@@ -4,6 +4,7 @@ interface CssExports {
'deleteButton': string;
'hideMetadataProfile': string;
'labelIcon': string;
'message': string;
}
export const cssExports: CssExports;
export default cssExports;
+5 -4
View File
@@ -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;
}