import I18n from "ex-react-native-i18n";
import { Localization } from 'expo-localization'
import { I18nManager } from "react-native";

import en from './en.json'
import es from './es.json'

I18n.translations = {
    en,
    es
}

const getLanguage = async() => {
 try {   const choice = await Localization.locale
    I18n.locale = choice.substr(0, 2)
    I18n.initAsync()
 }catch(error){
    console.log('Unable to get locale')
 }
}

getLanguage()

export function t(name){
    return I18n.t(name)
}