Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const App = () => {
const [locale, setLocale] = React.useState(Localization.locale || "en");
const appState = useAppState();
React.useEffect(() => {
// Localization only changes in Android (in iOS the app is restarted) and
// will only happen when the app comes back into the foreground
if (Platform.OS !== "android" || appState !== "active") return;
Localization.getLocalizationAsync()
.then(({ locale }) => setLocale(locale || "en"))
.catch(() => {});
}, [appState]);
// Add fallbacks for non-regional locales
const localeMessages = {
...messages[locale.split("-")[0]],
...(messages[locale] || {})
};
interface Props {}
interface States {
isReady: boolean;
}
if (__DEV__) {
setHostUrl(HOST_URL_DEV);
} else {
setHostUrl(HOST_URL_PROD);
}
// initialize locale from system language
store.dispatch({
type: SET_LOCALE,
locale: Localization.locale
});
// initialize toast provider using Toast from NativeBase
initToast(new ToastWrapper(store));
// initialize local storage provider
initStorage(AsyncStorage);
export default class App extends React.Component {
constructor(props: Props) {
super(props);
this.state = {
isReady: false,
};
}
async componentDidMount() {
// Load font resources for NativeBase
import i18n from 'i18n-js';
import chunk from 'lodash/chunk';
import React from 'react';
import { Picker, ScrollView, StyleSheet, Text, View } from 'react-native';
import * as Localization from 'expo-localization';
import HeadingText from '../components/HeadingText';
import ListButton from '../components/ListButton';
import MonoText from '../components/MonoText';
i18n.fallbacks = true;
i18n.locale = Localization.locale;
i18n.translations = {
en: {
phrase: 'Hello my friend',
default: 'English language only',
},
ru: {
phrase: 'Привет мой друг',
},
};
interface State {
isoCurrencyCodes: any;
currentLocale: any;
preferredLocales: any;
locale?: string;
}
import 'moment/min/locales'
import {
SafeAreaView,
Text,
Alert,
Platform,
TouchableOpacity,
AsyncStorage,
StyleSheet
} from 'react-native'
import api from '../services/api'
const deviceLanguage =
Localization.locale
.replace(/_/g, '-')
.toLowerCase()
moment.locale([
deviceLanguage,
'pt-br'
])
const DatePicker =
Platform.OS === 'ios'
? require('DatePickerIOS')
: require('../components/DatePickerAndroid')
export default ({ navigation }) => {
const [date, setDate] = useState(Platform.OS === 'ios' ? new Date(): '')
const id = navigation.getParam('id')
import * as Localization from 'expo-localization';
import Lng from 'i18n-js';
import en from './en.json';
import fr from './fr.json';
import es from './es.json';
Lng.fallbacks = true;
Lng.translations = {
en,
fr,
es
};
Lng.locale = Localization.locale;
export default Lng;
import i18n from 'i18n-js';
import * as Localization from 'expo-localization';
import en from './locale/en';
i18n.fallbacks = true;
i18n.translations = {
en
};
i18n.locale = Localization.locale;
export default function $t(key, params = {}) {
return i18n.t(key, params);
}
PASSWORD_CHANGE: '비밀번호 변경하기',
PASSWORD_CURRENT: '기존 비밀번호',
PASSWORD_NEW: '새로운 비밀번호',
PASSWORD_NEW_REPEAT: '새로운 비밀번호 확인',
NEXT: '다음',
OK: '확인',
CONFIRM: '확인',
LOGIN_INFORMATION: '계정 정보',
SIGNED_IN_WITH_GOOGLE: '구글 계정으로 로그인 됨',
SIGNED_IN_WITH_FACEBOOK: '페이스북 계정으로 로그인 됨',
SIGNED_IN_WITH_EMAIL: '이메일로 로그인 됨',
};
i18n.fallbacks = true;
i18n.translations = { en, ko };
i18n.locale = Localization.locale;
export const getString = (param: string, mapObj?: object): string => {
if (mapObj) {
i18n.t(param, mapObj);
}
return i18n.t(param);
};
it: it,
hu: hu,
fr: fr,
cz: cz,
ar: ar,
bn: bn,
hi: hi,
id: id,
zh: zh,
"zh_Hans-CN": zh_CN,
"zh-Hant-TW": zh_TW,
ka: ka,
tr: tr,
kn : kn
};
i18n.locale = Localization.locale;
i18n.defaultLocale = "en-EN";
export default i18n;
it,
ko,
pl,
es,
de,
fi,
nl,
ru,
"zh-Hans": zhHans,
"pt-PT": ptPT,
"pt-BR": ptBR,
nb,
sv,
ro,
};
i18n.locale = Localization.locale;
export default i18n;