Skip to content

Commit

Permalink
refactor(inji-467): remove additional i18n import statement
Browse files Browse the repository at this point in the history
Signed-off-by: Vijay <[email protected]>
  • Loading branch information
vijay151096 committed Nov 2, 2023
1 parent 9024f96 commit dc4400c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import i18n, {SUPPORTED_LANGUAGES} from '../i18n';
import {SUPPORTED_LANGUAGES} from '../i18n';
import {I18nManager, View} from 'react-native';
import {Picker} from './ui/Picker';
import {useTranslation} from 'react-i18next';
import i18next from 'i18next';
import i18next, {i18n} from 'i18next';
import RNRestart from 'react-native-restart';
import {setItem} from '../machines/store';
import Keychain from 'react-native-keychain';
Expand All @@ -20,18 +20,15 @@ export const LanguageSelector: React.FC<LanguageSelectorProps> = props => {
testID="language"
items={languages}
selectedValue={i18n.language}
onValueChange={language => changeLanguage(i18n.language, language)}
onValueChange={language => changeLanguage(i18n, language)}
triggerComponent={props.triggerComponent}
/>
</View>
);
};

export const changeLanguage = async (
currentLanguage: string,
language: string,
) => {
if (language !== currentLanguage) {
export const changeLanguage = async (i18n: i18n, language: string) => {
if (language !== i18n.language) {
await i18n.changeLanguage(language).then(async () => {
const existingCredentials = await Keychain.getGenericPassword();
await setItem('language', i18n.language, existingCredentials.password);
Expand Down
2 changes: 1 addition & 1 deletion screens/SetupLanguageScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const SetupLanguageScreen: React.FC<RootRouteProps> = props => {
testID="languagePicker"
items={languages}
selectedValue={i18n.language}
onValueChange={language => changeLanguage(i18n.language, language)}
onValueChange={language => changeLanguage(i18n, language)}
/>

<Button
Expand Down

0 comments on commit dc4400c

Please sign in to comment.