feat(i18n): implement deep merging for locale chunks and enhance Cebuano translations
All checks were successful
Deploy to production / deploy (push) Successful in 2m48s
All checks were successful
Deploy to production / deploy (push) Successful in 2m48s
- Introduced a deep merge function to combine locale chunks, improving the handling of language data for Cebuano. - Updated Cebuano locale files with comprehensive translations, including new sections for admin, social network, and settings. - Enhanced existing translations for clarity and consistency across various components, ensuring a better user experience. - Added new fields in the settings and profile sections to capture more user attributes, improving personalization options.
This commit is contained in:
@@ -80,6 +80,73 @@ import esMessage from './locales/es/message.json';
|
||||
import esPersonal from './locales/es/personal.json';
|
||||
import esSeo from './locales/es/seo.json';
|
||||
|
||||
function isPlainObject(value) {
|
||||
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
||||
}
|
||||
|
||||
/** Tiefes Zusammenführen von Locale-Chunks (ceb überschreibt en nur auf Blattebene, ohne ganze Teilbäume zu verwerfen). */
|
||||
function deepMerge(target, source) {
|
||||
if (!isPlainObject(source)) return target;
|
||||
const base = isPlainObject(target) ? { ...target } : {};
|
||||
for (const key of Object.keys(source)) {
|
||||
const sv = source[key];
|
||||
const tv = base[key];
|
||||
if (isPlainObject(sv) && isPlainObject(tv)) {
|
||||
base[key] = deepMerge(tv, sv);
|
||||
} else if (isPlainObject(sv)) {
|
||||
base[key] = deepMerge({}, sv);
|
||||
} else {
|
||||
base[key] = sv;
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
function mergeLocaleChunks(chunks) {
|
||||
return chunks.reduce((acc, chunk) => deepMerge(acc, chunk), {});
|
||||
}
|
||||
|
||||
const cebLocaleChunks = [
|
||||
enGeneral,
|
||||
enHeader,
|
||||
enNavigation,
|
||||
enHome,
|
||||
enChat,
|
||||
enRegister,
|
||||
enPasswordReset,
|
||||
enError,
|
||||
enActivate,
|
||||
enSettings,
|
||||
enAdmin,
|
||||
enSocialNetwork,
|
||||
enFriends,
|
||||
enFalukant,
|
||||
enBlog,
|
||||
enMinigames,
|
||||
enMessage,
|
||||
enPersonal,
|
||||
enSeo,
|
||||
cebGeneral,
|
||||
cebHeader,
|
||||
cebNavigation,
|
||||
cebHome,
|
||||
cebRegister,
|
||||
cebActivate,
|
||||
cebError,
|
||||
cebMessage,
|
||||
cebSettings,
|
||||
cebAdmin,
|
||||
cebPasswordReset,
|
||||
cebSocialNetwork,
|
||||
cebFriends,
|
||||
cebChat,
|
||||
cebPersonal,
|
||||
cebFalukant,
|
||||
cebBlog,
|
||||
cebMinigames,
|
||||
cebSeo,
|
||||
];
|
||||
|
||||
const messages = {
|
||||
en: {
|
||||
...enGeneral,
|
||||
@@ -102,45 +169,7 @@ const messages = {
|
||||
...enPersonal,
|
||||
...enSeo,
|
||||
},
|
||||
ceb: {
|
||||
...enGeneral,
|
||||
...enHeader,
|
||||
...enNavigation,
|
||||
...enHome,
|
||||
...enChat,
|
||||
...enRegister,
|
||||
...enPasswordReset,
|
||||
...enError,
|
||||
...enActivate,
|
||||
...enSettings,
|
||||
...enAdmin,
|
||||
...enSocialNetwork,
|
||||
...enFriends,
|
||||
...enFalukant,
|
||||
...enBlog,
|
||||
...enMinigames,
|
||||
...enMessage,
|
||||
...enPersonal,
|
||||
...cebGeneral,
|
||||
...cebHeader,
|
||||
...cebNavigation,
|
||||
...cebHome,
|
||||
...cebRegister,
|
||||
...cebActivate,
|
||||
...cebError,
|
||||
...cebMessage,
|
||||
...cebSettings,
|
||||
...cebAdmin,
|
||||
...cebPasswordReset,
|
||||
...cebSocialNetwork,
|
||||
...cebFriends,
|
||||
...cebChat,
|
||||
...cebPersonal,
|
||||
...cebFalukant,
|
||||
...cebBlog,
|
||||
...cebMinigames,
|
||||
...cebSeo,
|
||||
},
|
||||
ceb: mergeLocaleChunks(cebLocaleChunks),
|
||||
de: {
|
||||
'Ok': 'Ok',
|
||||
...deGeneral,
|
||||
|
||||
Reference in New Issue
Block a user