Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 995x 995x 7391x 7391x 7391x 14780x 14778x 2x 2x 5x 2x 7389x 995x | /**
* Composable for UI language management
* Uses the user's language preferences to determine interface language
* Supported UI languages are defined in locales/index.ts
*/
import { computed } from 'vue'
import { uiTranslations, type UILanguage } from '@/locales'
import { useLanguage } from './useLanguage'
export function useUILanguage() {
const { preferredUILanguage } = useLanguage()
// UI language is driven by the user's preferred UI language,
// independent of the tenant's content language settings (enabledLanguages).
const uiLanguage = computed<UILanguage>(() => preferredUILanguage.value as UILanguage)
/**
* Get translation for a key path (e.g., 'common.cancel')
*/
function t(keyPath: string): string {
const keys = keyPath.split('.')
let value: any = uiTranslations[uiLanguage.value]
for (const key of keys) {
if (value && typeof value === 'object') {
value = value[key]
} else {
// Fallback to English if translation missing
let fallback: any = uiTranslations.en
for (const k of keys) {
fallback = fallback?.[k]
}
return fallback || keyPath
}
}
return typeof value === 'string' ? value : keyPath
}
return {
uiLanguage,
t
}
}
|