support for translations in location content; translations for locations
This commit is contained in:
@ -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}]`;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user