Refactor localization and simplify HomeScreen functionality

- Removed English and Russian localization files, focusing solely on Turkmen.
- Simplified language initialization in i18n.ts to default to Turkmen.
- Cleaned up HomeScreen by removing modal for language selection and related state management.
This commit is contained in:
Mekan1206
2025-09-17 19:25:49 +05:00
parent acddbf48f0
commit c2cd61c679
5 changed files with 3 additions and 148 deletions

17
i18n.ts
View File

@@ -1,29 +1,16 @@
import { I18n } from 'i18n-js';
import * as Localization from 'expo-localization';
import AsyncStorage from '@react-native-async-storage/async-storage';
import en from './locales/en.json';
import tk from './locales/tk.json';
import ru from './locales/ru.json';
const i18n = new I18n({
en,
tk,
ru,
});
i18n.locale = 'tk';
i18n.enableFallback = true;
// Function to initialize the language
export const initializeLanguage = async () => {
const savedLanguage = await AsyncStorage.getItem('user-language');
if (savedLanguage) {
i18n.locale = savedLanguage;
} else {
// If no language is saved, detect from device and default to Turkmen
const userLanguageCode = Localization.getLocales()[0]?.languageCode;
i18n.locale = ['en', 'tk', 'ru'].includes(userLanguageCode || '') ? userLanguageCode! : 'tk';
}
i18n.locale = 'tk';
};
export default i18n;