NMF-earth / nmf-app

Understand and reduce your carbon footprint 🌱 iOS & Android.
https://nmf.earth
GNU General Public License v3.0
506 stars 156 forks source link

Setup localisation #6

Closed theolampert closed 4 years ago

theolampert commented 4 years ago

One possibility: https://docs.expo.io/versions/latest/sdk/localization/

PierreBresson commented 4 years ago

Humm... What's the point of using expo-localization plus i18n? Why not just i18n? Just thinking about what happen if we eject app from expo

theolampert commented 4 years ago

I'm not sure it's the best way actually I just saw it in the docs. I think i18n does not concern itself with detetecting the device language / country / currency while expo-localization provides some abstraction for that. There might be another package less specific to expo though.

PierreBresson commented 4 years ago

I don't understand much from the doc of i18n-js : https://github.com/fnando/i18n-js react-i18next seems easier https://github.com/i18next/react-i18next The ideal would be to have something like : my-component folder with inside my-component.tsx and then a translation folder with inside en.ts,fr.ts... Translation file for e.g fr.ts should look like : export default { SAY_HELLO: 'Bonjour!' } And then use it like this : <Text>{t('SAY_HELLO')}</Text>

PierreBresson commented 4 years ago

I'm not sure it's the best way actually I just saw it in the docs. I think i18n does not concern itself with detetecting the device language / country / currency while expo-localization provides some abstraction for that. There might be another package less specific to expo though.

Humm I see, let's use expo right now. Other packages I've seen need linking so we can't use them

theolampert commented 4 years ago

Yeah I'm not super familiar with how to do it in RN / expo maybe it's straightforward to get the device locale and just use i18n-js I can do a bit more research.