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:
BIN
.i18n.ts.swp
Normal file
BIN
.i18n.ts.swp
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
import { StyleSheet, ScrollView, I18nManager, Modal, Pressable } from 'react-native';
|
import { StyleSheet, ScrollView } from 'react-native';
|
||||||
import { Text, View } from '@/components/Themed';
|
import { Text, View } from '@/components/Themed';
|
||||||
import FeatureCard from '@/components/FeatureCard';
|
import FeatureCard from '@/components/FeatureCard';
|
||||||
import PrayerTimeCard from '@/components/PrayerTimeCard';
|
import PrayerTimeCard from '@/components/PrayerTimeCard';
|
||||||
@@ -12,16 +12,13 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|||||||
|
|
||||||
|
|
||||||
export default function HomeScreen() {
|
export default function HomeScreen() {
|
||||||
const [modalVisible, setModalVisible] = useState(false);
|
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
|
|
||||||
const changeLanguage = async (lang: 'en' | 'tk' | 'ru') => {
|
const changeLanguage = async (lang: 'en' | 'tk' | 'ru') => {
|
||||||
if (!lang) return;
|
if (!lang) return;
|
||||||
setModalVisible(false);
|
|
||||||
if (lang === i18n.locale.substring(0, 2)) return;
|
if (lang === i18n.locale.substring(0, 2)) return;
|
||||||
await AsyncStorage.setItem('user-language', lang);
|
await AsyncStorage.setItem('user-language', lang);
|
||||||
i18n.locale = lang;
|
i18n.locale = lang;
|
||||||
I18nManager.forceRTL(false); // Assuming LTR for all three languages
|
|
||||||
Updates.reloadAsync();
|
Updates.reloadAsync();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,31 +41,8 @@ export default function HomeScreen() {
|
|||||||
|
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<Text style={styles.title}>{i18n.t('home')}</Text>
|
<Text style={styles.title}>{i18n.t('home')}</Text>
|
||||||
<Pressable onPress={() => setModalVisible(true)} style={pickerSelectStyles.inputIOS}>
|
|
||||||
<Text style={{ color: 'white' }}>{currentLanguage}</Text>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Modal
|
|
||||||
animationType="slide"
|
|
||||||
transparent={true}
|
|
||||||
visible={modalVisible}
|
|
||||||
onRequestClose={() => {
|
|
||||||
setModalVisible(!modalVisible);
|
|
||||||
}}>
|
|
||||||
<Pressable style={styles.modalOverlay} onPress={() => setModalVisible(false)}>
|
|
||||||
<View style={styles.modalView}>
|
|
||||||
{languages.map((lang) => (
|
|
||||||
<Pressable
|
|
||||||
key={lang.value}
|
|
||||||
style={styles.modalButton}
|
|
||||||
onPress={() => changeLanguage(lang.value as 'en' | 'tk' | 'ru')}>
|
|
||||||
<Text style={styles.modalButtonText}>{lang.label}</Text>
|
|
||||||
</Pressable>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
</Pressable>
|
|
||||||
</Modal>
|
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<View style={styles.innerContainer}>
|
<View style={styles.innerContainer}>
|
||||||
{/* <FeatureCard
|
{/* <FeatureCard
|
||||||
|
|||||||
17
i18n.ts
17
i18n.ts
@@ -1,29 +1,16 @@
|
|||||||
import { I18n } from 'i18n-js';
|
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 tk from './locales/tk.json';
|
||||||
import ru from './locales/ru.json';
|
|
||||||
|
|
||||||
const i18n = new I18n({
|
const i18n = new I18n({
|
||||||
en,
|
|
||||||
tk,
|
tk,
|
||||||
ru,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
i18n.locale = 'tk';
|
||||||
i18n.enableFallback = true;
|
i18n.enableFallback = true;
|
||||||
|
|
||||||
// Function to initialize the language
|
// Function to initialize the language
|
||||||
export const initializeLanguage = async () => {
|
export const initializeLanguage = async () => {
|
||||||
const savedLanguage = await AsyncStorage.getItem('user-language');
|
i18n.locale = 'tk';
|
||||||
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';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
{
|
|
||||||
"home": "Home",
|
|
||||||
"services": "Services",
|
|
||||||
"supplications": "Supplications",
|
|
||||||
"yourJourneyToHajj": "Your Journey to Hajj",
|
|
||||||
"hajjEssentials": "Everything you need for Hajj essentials.",
|
|
||||||
"umrah": "Umrah",
|
|
||||||
"bookPermit": "Book Permit",
|
|
||||||
"nobleRawdah": "Noble Rawdah",
|
|
||||||
"newExperience": "New Experience",
|
|
||||||
"prayerTimes": "Prayer Times",
|
|
||||||
"programs": "Programs",
|
|
||||||
"Programs": "Schedule",
|
|
||||||
"leftOnPrayer": "Left on {{prayerName}} prayer",
|
|
||||||
"servicesToEnrich": "Services to Enrich Your Spiritual Experience",
|
|
||||||
"quran": "Qur'an",
|
|
||||||
"hadith": "Hadith",
|
|
||||||
"dua": "Dua",
|
|
||||||
"currencyConverter": "Currency Converter",
|
|
||||||
"hotelCard": "Hotel Card",
|
|
||||||
"lostKey": "Lost Key?",
|
|
||||||
"translator": "Translator",
|
|
||||||
"adhkar": "Adhkar",
|
|
||||||
"hisnAlMuslim": "Hisn Al-Muslim",
|
|
||||||
"Makkah": "Makkah",
|
|
||||||
"Medina": "Medina",
|
|
||||||
"Jeddah": "Jeddah",
|
|
||||||
"fajr": "Fajr",
|
|
||||||
"sunrise": "Sunrise",
|
|
||||||
"dhuhr": "Dhuhr",
|
|
||||||
"asr": "Asr",
|
|
||||||
"maghrib": "Maghrib",
|
|
||||||
"isha": "Isha",
|
|
||||||
"morningEveningThikr": "Thikr said in the morning and evening",
|
|
||||||
"beforeSleepingThikr": "Thikr before sleeping",
|
|
||||||
"afterSalamThikr": "Thikr after salam",
|
|
||||||
"breakingFastSupplication": "Upon breaking fast",
|
|
||||||
"fastingPersonSupplication": "Supplication said by one fasting when presented with food and does not break his fast",
|
|
||||||
"insultedWhileFasting": "When insulted while fasting",
|
|
||||||
"seeingFruitSupplication": "Supplication upon seeing the early or premature fruit",
|
|
||||||
"sneezingSupplication": "Supplication upon sneezing",
|
|
||||||
"sarToTmt": "SAR to TMT",
|
|
||||||
"hotelBusinessCard": "Hotel Business Card",
|
|
||||||
"masterkeyBox": "Masterkey Box",
|
|
||||||
"Money": "Money",
|
|
||||||
"Hotel": "Hotel",
|
|
||||||
"Lost room key": "Lost room key",
|
|
||||||
"Phrasebook": "Phrasebook",
|
|
||||||
"Enter text in Turkmen": "Enter text",
|
|
||||||
"Translate": "Translate",
|
|
||||||
"Salah": "Salah",
|
|
||||||
"menuSalah": "Salah"
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
{
|
|
||||||
"home": "Главная",
|
|
||||||
"services": "Сервисы",
|
|
||||||
"supplications": "Молитвы",
|
|
||||||
"yourJourneyToHajj": "Ваше путешествие в Хадж",
|
|
||||||
"hajjEssentials": "Все, что вам нужно для Хаджа.",
|
|
||||||
"umrah": "Умра",
|
|
||||||
"bookPermit": "Забронировать разрешение",
|
|
||||||
"nobleRawdah": "Благородная Равда",
|
|
||||||
"newExperience": "Новый опыт",
|
|
||||||
"prayerTimes": "Время молитв",
|
|
||||||
"programs": "Программы",
|
|
||||||
"Programs": "Расписание",
|
|
||||||
"leftOnPrayer": "Осталось до молитвы {{prayerName}}",
|
|
||||||
"servicesToEnrich": "Услуги для обогащения вашего духовного опыта",
|
|
||||||
"quran": "Коран",
|
|
||||||
"hadith": "Хадис",
|
|
||||||
"dua": "Дуа",
|
|
||||||
"currencyConverter": "Конвертер валют",
|
|
||||||
"hotelCard": "Карта отеля",
|
|
||||||
"lostKey": "Потеряли ключ?",
|
|
||||||
"translator": "Переводчик",
|
|
||||||
"adhkar": "Азкар",
|
|
||||||
"hisnAlMuslim": "Крепость мусульманина",
|
|
||||||
"Makkah": "Мекка",
|
|
||||||
"Medina": "Медина",
|
|
||||||
"Jeddah": "Джидда",
|
|
||||||
"fajr": "Фаджр",
|
|
||||||
"sunrise": "Восход",
|
|
||||||
"dhuhr": "Зухр",
|
|
||||||
"asr": "Аср",
|
|
||||||
"maghrib": "Магриб",
|
|
||||||
"isha": "Иша",
|
|
||||||
"morningEveningThikr": "Зикр, читаемый утром и вечером",
|
|
||||||
"beforeSleepingThikr": "Зикр перед сном",
|
|
||||||
"afterSalamThikr": "Зикр после салама",
|
|
||||||
"breakingFastSupplication": "При разговении",
|
|
||||||
"fastingPersonSupplication": "Мольба, произносимая постящимся, когда ему преподносят еду, и он не прерывает свой пост",
|
|
||||||
"insultedWhileFasting": "Когда оскорбляют во время поста",
|
|
||||||
"seeingFruitSupplication": "Мольба при виде ранних или незрелых плодов",
|
|
||||||
"sneezingSupplication": "Мольба при чихании",
|
|
||||||
"sarToTmt": "SAR в TMT",
|
|
||||||
"hotelBusinessCard": "Визитная карточка отеля",
|
|
||||||
"masterkeyBox": "Ящик для мастер-ключей",
|
|
||||||
"Money": "Деньги",
|
|
||||||
"Hotel": "Отель",
|
|
||||||
"Lost room key": "Ключ от номера утерян",
|
|
||||||
"Phrasebook": "Разговорник",
|
|
||||||
"Enter text in Turkmen": "Введите текст",
|
|
||||||
"Translate": "Перевести",
|
|
||||||
"Salah": "Намаз",
|
|
||||||
"menuSalah": "Намаз"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user