Skip to content

Commit

Permalink
use system language
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrunk committed Nov 18, 2023
1 parent 3b3af58 commit d687b1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/screens/Startup/Startup.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import React, { useEffect } from 'react';
import { ActivityIndicator, View } from 'react-native';
import { ActivityIndicator, View, NativeModules, Platform } from 'react-native';
import { useTranslation } from 'react-i18next';
import { useTheme } from '../../hooks';
import { Brand } from '../../components';
import PoweredByFlux from '../../components/PoweredByFlux/PoweredByFlux';
import { setDefaultTheme } from '../../store/theme';
import { ApplicationScreenProps } from '../../../@types/navigation';

const Startup = ({ navigation }: ApplicationScreenProps) => {
const { i18n } = useTranslation();
const { Layout, Gutters } = useTheme();

const init = async () => {
const deviceLanguage =
Platform.OS === 'ios'
? NativeModules.SettingsManager.settings.AppleLocale ||
NativeModules.SettingsManager.settings.AppleLanguages[0] // iOS 13
: NativeModules.I18nManager.localeIdentifier;

console.log(deviceLanguage); // en_US
await i18n.changeLanguage(deviceLanguage.split('_')[0].split('-')[0]); // use system language
await new Promise((resolve) =>
setTimeout(() => {
resolve(true);
Expand Down
2 changes: 1 addition & 1 deletion src/translations/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as en } from './en/_index';
export { default as fr } from './fr/_index';
export { default as id } from './id/_index';

0 comments on commit d687b1e

Please sign in to comment.