support for translations in location content; translations for locations
This commit is contained in:
@ -32,5 +32,13 @@
|
|||||||
"statistics": "Статистика",
|
"statistics": "Статистика",
|
||||||
"coverMeLogs": "Замествания",
|
"coverMeLogs": "Замествания",
|
||||||
"translations": "Преводи"
|
"translations": "Преводи"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"location": {
|
||||||
|
"warehouse": {
|
||||||
|
"description": "- снимки как да се поставят количките\n- снимка с код за катинар\nвсеки може да всима/връща\n- преди да влизаме трябва да почистим краката.\n- зареждаме/почистваме извън\n- влизане/озлизане няма код\n- влизане/излизане има код",
|
||||||
|
"title": "СНЛАД"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,5 +32,13 @@
|
|||||||
"statistics": "View Statistics",
|
"statistics": "View Statistics",
|
||||||
"coverMeLogs": "View CoverMe logs",
|
"coverMeLogs": "View CoverMe logs",
|
||||||
"translations": "Translation"
|
"translations": "Translation"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"location": {
|
||||||
|
"warehouse": {
|
||||||
|
"description": "- снимки как да се поставят количките\n- снимка с код за катинар\nвсеки може да всима/връща\n- преди да влизаме трябва да почистим краката.\n- зареждаме/почистваме извън\n- влизане/озлизане няма код\n- влизане/излизане има код",
|
||||||
|
"title": "СНЛАД"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,10 +8,17 @@
|
|||||||
"BG": "болгарский",
|
"BG": "болгарский",
|
||||||
"EN": "английский",
|
"EN": "английский",
|
||||||
"RU": "русский",
|
"RU": "русский",
|
||||||
"login": "вход",
|
"login": "вход"
|
||||||
"contacts": "Контакти te"
|
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"dashboard": "Начало"
|
"dashboard": "Начало"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"location": {
|
||||||
|
"warehouse": {
|
||||||
|
"description": "- снимки как да се поставят количките\n- снимка с код за катинар\nвсеки може да всима/връща\n- преди да влизаме трябва да почистим краката.\n- зареждаме/почистваме извън\n- влизане/озлизане няма код\n- влизане/излизане има код",
|
||||||
|
"title": "СНЛАД"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -112,9 +112,16 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
|||||||
const placeholderPattern = /{([^}]+)}/g;
|
const placeholderPattern = /{([^}]+)}/g;
|
||||||
return content.replace(placeholderPattern, (match, key) => {
|
return content.replace(placeholderPattern, (match, key) => {
|
||||||
try {
|
try {
|
||||||
return t(key);
|
const translation = t('content.' + key);
|
||||||
|
// Check if translation exists and is not empty
|
||||||
|
if (translation && translation !== 'content.' + key) {
|
||||||
|
return translation;
|
||||||
|
}
|
||||||
|
// Return formatted placeholder if translation not found
|
||||||
|
return `[${locale}:${key}]`;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return match;
|
// Return formatted placeholder on error
|
||||||
|
return `[${locale}:${key}]`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user