Skip to content

Commit 90107c5

Browse files
committed
fix styles
1 parent 4dd170e commit 90107c5

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

client/src/helpers/servicesI18n.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,17 @@ export const getServiceTranslation = (t: (key: string) => any, key: string): str
3939
const currentLang = i18next.language?.toLowerCase() || 'en';
4040
const fallbackLangs = ['en', BASE_LOCALE.toLowerCase(), currentLang].filter((lang, idx, arr) => arr.indexOf(lang) === idx);
4141

42-
for (const lang of fallbackLangs) {
43-
const servicesDict = cache[lang];
44-
console.log('Checking cache for lang:', { lang, hasDict: !!servicesDict, hasKey: servicesDict?.[key] });
45-
if (servicesDict && servicesDict[key]) {
46-
const translation = servicesDict[key] as TranslationObject;
47-
console.log('Found in cache:', { lang, key, translation });
48-
if (typeof translation === 'string') {
49-
return translation;
50-
}
51-
if (translation && typeof translation === 'object' && 'message' in translation) {
52-
return translation.message;
53-
}
42+
const foundTranslation = fallbackLangs
43+
.map(lang => ({ lang, servicesDict: cache[lang] }))
44+
.find(({ servicesDict }) => servicesDict && servicesDict[key]);
45+
46+
if (foundTranslation) {
47+
const translation = foundTranslation.servicesDict[key] as TranslationObject;
48+
if (typeof translation === 'string') {
49+
return translation;
50+
}
51+
if (translation && typeof translation === 'object' && 'message' in translation) {
52+
return translation.message;
5453
}
5554
}
5655

0 commit comments

Comments
 (0)