(key: string)
| 37 | }; |
| 38 | |
| 39 | const t = (key: string): string => { |
| 40 | const keys = key.split('.'); |
| 41 | let result: any = translations[language]; |
| 42 | for (const k of keys) { |
| 43 | result = result?.[k]; |
| 44 | if (result === undefined) { |
| 45 | // Fallback to English if key not found in current language |
| 46 | let fallbackResult: any = translations['en']; |
| 47 | for (const fk of keys) { |
| 48 | fallbackResult = fallbackResult?.[fk]; |
| 49 | } |
| 50 | return fallbackResult || key; |
| 51 | } |
| 52 | } |
| 53 | return result || key; |
| 54 | }; |
| 55 | |
| 56 | return ( |
| 57 | <LanguageContext.Provider value={{ language, changeLanguage, t }}> |
no outgoing calls
no test coverage detected