How can I make my React-native application identify our language?

-1

When I insert text, eg:

<Text>Maçã</Text>

It does not recognize! I know it's the utf8 goal, but I do not know where to insert it! Thank you in advance!

    
asked by anonymous 15.11.2018 / 08:10

2 answers

0

From what I understand, you want to internationalize your application, correct? You'll need a plugin, like the:

link

npm install --save react-native-languages
react-native link react-native-languages

Usage:

import RNLanguages from 'react-native-languages';

// Current device language
console.log('language', RNLanguages.language);

// User preferred languages (in order)
console.log('languages', RNLanguages.languages);

// Listening for languages changes (on Android)
RNLanguages.addEventListener('change', ({ language, languages }) => {
  // Do languages related things…
});

You also have link

npm install react-native-localization --save
react-native link react-native-localization

And you can use creating components for the location

// ES6 module syntax
import LocalizedStrings from 'react-native-localization';

// CommonJS syntax
// let LocalizedStrings  = require ('react-native-localization');

let strings = new LocalizedStrings({
 "en-US":{
   how:"How do you want your egg today?",
   boiledEgg:"Boiled egg",
   softBoiledEgg:"Soft-boiled egg",
   choice:"How to choose the egg"
 },
 en:{
   how:"How do you want your egg today?",
   boiledEgg:"Boiled egg",
   softBoiledEgg:"Soft-boiled egg",
   choice:"How to choose the egg"
 },
 it: {
   how:"Come vuoi il tuo uovo oggi?",
   boiledEgg:"Uovo sodo",
   softBoiledEgg:"Uovo alla coque",
   choice:"Come scegliere l'uovo"
 }
});

And call

<Text style={styles.title}>
  {strings.how}
</Text>
    
15.11.2018 / 10:44
0

Solved! My publisher configuration was not for utf8! As soon as I set it to utf8 , the characters appeared. Thanks for the help!

    
16.11.2018 / 17:06