GithubHelp home page GithubHelp logo

Comments (11)

zoontek avatar zoontek commented on June 13, 2024 8

You can apply some configuration before I18n is loaded:

I18n.defaultLocale = 'pt-BR'

More infos here https://github.com/fnando/i18n-js#setting-up

from react-native-i18n.

diegorodriguesvieira avatar diegorodriguesvieira commented on June 13, 2024

thanks dude =)

from react-native-i18n.

chemitaxis avatar chemitaxis commented on June 13, 2024

Hi, I'm having some problem configuration with this plugin...

My device is on English, and I would like that Spanish Language was the default language, if for example, an Italian Device install the app the language default must be Spanish. But my device is ignoring my language device (en output of I18n.currentLocale() function)

This is my current configuration and code:


// Import 
import I18n from 'react-native-i18n';

.. stuff code ...

// Configuration I18n

I18n.defaultLocale = 'es-ES';
I18n.fallbacks = true;
I18n.translations = {
    en: {
        greeting: 'Hi!'
    },
    es: {
        greeting: 'Hola!'
    }

};

.. stuff code ...

// Component Class and StyleSheet code... 

export default class MyScreen extends Component {
    render() {
       return (
               <View>
                     <Text style={styles.signupLinkText}>{I18n.t('greeting')}</Text>
               </View>
                  )
     }
}


Output desired:

Italian Device -> locale (it) -> greeting message -> Hola!
Spanish Device -> locale (es) -> greeting message -> Hola!
USA Device -> locale (en-US) -> greeting message -> Hi!
UK Device -> locale (en-UK) -> greeting message -> Hi!

Thank you so much!! Excellent work!!

from react-native-i18n.

chemitaxis avatar chemitaxis commented on June 13, 2024

Hi, I solved adding this to my configuration:

I18n.locale = I18n.currentLocale();

I think that this is a bug, check this: #43

from react-native-i18n.

isener avatar isener commented on June 13, 2024

But we can not get the devices default locale. It always returns 'en'

from react-native-i18n.

chemitaxis avatar chemitaxis commented on June 13, 2024

@isener Ok, you are right... always return 'en', I don't know why in one moment, it was returning other language, sorry for the mistake...

from react-native-i18n.

isener avatar isener commented on June 13, 2024

@chemitaxis mate I couldn't resolved why it happened. If I would, also notice to you. Thanks

from react-native-i18n.

chemitaxis avatar chemitaxis commented on June 13, 2024

from react-native-i18n.

Andriiklymiuk avatar Andriiklymiuk commented on June 13, 2024

Somebody solved it?

from react-native-i18n.

samuelematias avatar samuelematias commented on June 13, 2024

This is dont work:
I18n.defaultLocale = 'pt-BR'

from react-native-i18n.

samuelematias avatar samuelematias commented on June 13, 2024

When my app doesn't have the translations, I put I18n.locale = 'pt-BR'; rather than I18n.defaultLocale = 'pt-BR' and works.

from react-native-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.