support for translations in location content; translations for locations

This commit is contained in:
Dobromir Popov
2024-11-05 00:40:16 +02:00
parent 08b1a78e32
commit 6b76f27351
4 changed files with 34 additions and 4 deletions

View File

@ -112,9 +112,16 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const placeholderPattern = /{([^}]+)}/g;
return content.replace(placeholderPattern, (match, key) => {
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) {
return match;
// Return formatted placeholder on error
return `[${locale}:${key}]`;
}
});
};