sozsoft-platform/ui/src/utils/translate.ts

14 lines
692 B
TypeScript
Raw Normal View History

2026-10-17 18:51:10 +00:00
import { store } from '@/store'
import { getLocalization } from '@/services/localization.service'
/**
* React dışı kodda (axios interceptor, SignalR servisi, modül düzeyi yardımcılar) aktif dilde
* çeviri. Bileşenlerde `useLocalization` kullanılır; bu yardımcı yalnızca hook'un
* çağrılamadığı yerler içindir. Metinler henüz yüklenmediyse anahtarın kendisi döner.
*/
export const translateStatic = (key: string, params?: Record<string, string | number>): string => {
const { texts, config } = store.getState().abpConfig
if (!texts) return key.split('::').pop() || key
return getLocalization(texts, config?.localization?.defaultResourceName, key, params)
}