Files
info-tager-mobile/i18n/useLanguage.ts
Samandar Turgunboyev 124798419b fitst commit
2026-01-28 18:26:50 +05:00

32 lines
595 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 { useTranslation } from 'react-i18next';
export type Lang = 'uz' | 'ru' | 'en';
export function useLanguage() {
const { i18n, t } = useTranslation();
const changeLanguage = async (lang: Lang) => {
await i18n.changeLanguage(lang);
};
const getLanguageName = () => {
switch (i18n.language) {
case 'uz':
return 'Ozbek';
case 'ru':
return 'Русский';
case 'en':
return 'English';
default:
return '';
}
};
return {
t,
language: i18n.language,
changeLanguage,
getLanguageName,
};
}