title: How to get current locale with React-Native and i18n-js?
body: <p>I'm trying to get current locale from the device of the user.
  For now, I have 2 versions of my app : french and english.
  It works fine when I change the fallback language I do have the two versions of the app.
  But I can't manage to change the language directly from the device...</p>
  <p>I used RNlocalize as seen in many pages but it doesn't work for me... my App.js:</p>
  <pre><code>import React, { Component } from &quot;react&quot;;
  import I18n from &quot;./src/i18n/I18n&quot;;
  import * as RNLocalize from &quot;react-native-localize&quot;;
  
  async handleLocales() {
    this.locales = RNLocalize.getLocales();
  }
  
  getLocale() {
    if (this.locales) {
      if (Array.isArray(this.locales)) {
        return this.locales[0];
      }
    }
    return null;
  }
  class App extends Component {
    render() {
      return (
        &lt;View&gt;
          &lt;Text&gt;{I18n.t(&quot;hello&quot;)}&lt;/Text&gt;
        &lt;/View&gt;
      );
    }
  }
  export default App;
  </code></pre>
  <p>My i18n.js file :</p>
  <pre><code>import I18n from &quot;i18n-js&quot;;
  import * as RNLocalize from &quot;react-native-localize&quot;;
  
  import en from &quot;./locales/en&quot;;
  import fr from &quot;./locales/fr&quot;;
  
  const locales = RNLocalize.getLocales();
  
  if (Array.isArray(locales)) {
    I18n.locale = locales[0].languageTag;
  }
  
  I18n.fallbacks = true;
  I18n.translations = {
    en,
    fr
  };
  
  export default I18n;
  </code></pre>
  <p>I tried it in a test folder. The error I've got is</p>
  <blockquote>
  <pre><code>SyntaxError: C:\Users\Administrateur\Desktop\App.js: Unexpected token, expected &quot;=&gt;&quot; (5:19)
  
    3 | import * as RNLocalize from &quot;react-native-localize&quot;;
    4 | 
  &gt; 5 | async handleLocales() {
      |                    ^
    6 |   this.locales = RNLocalize.getLocales();
    7 | }
    8 |
  </code></pre>
  </blockquote>