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 'O‘zbek';
      case 'ru':
        return 'Русский';
      case 'en':
        return 'English';
      default:
        return '';
    }
  };

  return {
    t,
    language: i18n.language,
    changeLanguage,
    getLanguageName,
  };
}
