sozsoft-platform/ui/src/utils/translate.ts
2026-10-17 21:51:10 +03:00

13 lines
692 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
}