intl package add and fallback

This commit is contained in:
Feruz 2018-11-20 12:26:01 +02:00
parent a3f7056f4f
commit 81319d1b35
3 changed files with 16 additions and 4 deletions

7
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "eSteem", "name": "eSteem",
"version": "0.0.1", "version": "2.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -5337,6 +5337,11 @@
} }
} }
}, },
"intl": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/intl/-/intl-1.2.5.tgz",
"integrity": "sha1-giRKIZDE5Bn4Nx9ao02qNCDiq94="
},
"intl-format-cache": { "intl-format-cache": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-2.1.0.tgz", "resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-2.1.0.tgz",

View File

@ -29,6 +29,7 @@
"axios": "^0.18.0", "axios": "^0.18.0",
"crypto-js": "^3.1.9-1", "crypto-js": "^3.1.9-1",
"dsteem": "^0.10.1", "dsteem": "^0.10.1",
"intl": "^1.2.5",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"moment": "^2.22.2", "moment": "^2.22.2",
"native-base": "^2.8.1", "native-base": "^2.8.1",

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { Dimensions } from 'react-native'; import { Dimensions } from 'react-native';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import 'intl';
import { IntlProvider, addLocaleData } from 'react-intl'; import { IntlProvider, addLocaleData } from 'react-intl';
import en from 'react-intl/locale-data/en'; import en from 'react-intl/locale-data/en';
import tr from 'react-intl/locale-data/tr'; import tr from 'react-intl/locale-data/tr';
@ -11,8 +12,6 @@ import { ReduxNavigation } from './config/reduxNavigation';
import { flattenMessages } from './utils/flattenMessages'; import { flattenMessages } from './utils/flattenMessages';
import messages from './config/locales'; import messages from './config/locales';
addLocaleData([...en, ...tr]);
// STYLE // STYLE
EStyleSheet.build({ EStyleSheet.build({
@ -48,12 +47,19 @@ EStyleSheet.build({
$primaryLatterSpacing: 0, $primaryLatterSpacing: 0,
}); });
const locale = 'en-US'; addLocaleData([...en, ...tr]);
const locale = (navigator.languages && navigator.languages[0])
|| navigator.language
|| navigator.userLanguage
|| 'en-US';
export default () => ( export default () => (
<Provider store={store}> <Provider store={store}>
<IntlProvider locale={locale} messages={flattenMessages(messages[locale])}> <IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
<ReduxNavigation /> <ReduxNavigation />
</IntlProvider> </IntlProvider>
</Provider> </Provider>
); );