13 lines
692 B
TypeScript
13 lines
692 B
TypeScript
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)
|
||
}
|