react-native-datepicker
react-native-datepicker copied to clipboard
[help] how to change locale ?
DatePicker~ i Love it ^^;
but, i don't know how to change moment locale()
help me please ~
I have this question too ..
Same problem, any idea?
Hi guys ! @dcolin @ddpdev It depends on what your device locale setting ,when I run on my iPhone ,everything works well for now ...
@rocwangv You're right! It works well on my simulator and my device.
So... But I have another problem. The format in my app is defined by user profile. His device is English but his config is Portuguese. So... the correctly format is Protuguese
Hey guys, maybe this still help someone:
import moment from 'moment'
import 'moment/locale/pt-br'
moment.locale('pt-BR')
You can set this at any point of the app and to set it globally you can put in app.js for example.
Valeu, César!
If you only consider IOS, another way to work around is that, we can config global locale for UIDatePicker in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions.
E.g.
[[UIDatePicker appearance] setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh-Hans"]];
Hello guys, I want to have the month's names inside the picker use Vietnamese. I've tried @cesarcosta99 solution but it doesn't work. Do anyone has the solution for this? thanks.
import Moment from "moment";
require("moment/locale/vi");
Moment.locale("vi");
Well @DanteEvil that's weird, did you check if vi.js file is in the moment/locale folder inside node_modules? Either way you can update an existing locale and even create a custom locale to achieve what you want, check this out: Moment Customization.
My fork include this feature: https://github.com/pablo-albaladejo/react-native-datepicker
<DatePicker locale={'es'} date={this.state.date} mode='date'/>
Hello guys, I want to have the month's names inside the picker use Vietnamese. I have to try many solutions but it can't work. Please help me.
@ngocnguyen09910060 my fork works:
<DatePicker locale={'vi'} date={this.state.date} mode='date'/>
provides:

Hi Mr @pablo-albaladejo, Thanks you for your help. I'm a newbie in React Native. Can you explain steps to integrate your fork to an exist project? This is my package information: "react": "16.0.0", "react-native": "0.50.0", "react-native-datepicker": "^1.6.0", I added locale={'vi'} to <DatePicker> but it isn't work. Please help me.
Hi @ngocnguyen09910060
Update you package.json as follows:
"react": "16.2.0",
"react-native": "0.52.0",
"react-native-datepicker": "git+https://github.com/pablo-albaladejo/react-native-datepicker.git",
and run
rm -rf node_modules && npm install
@wxy325 thanks, solved one of my pain points.
FYI: This has been fixed in version 1.7.0
Locale seems to be still ignored, at least for Android. Tried things like <DatePicker locale='en' or <DatePicker locale={I18n.locale} (after manually changing I18n.locale and seeing it taking effect on other things). No effect, datepicker still in default phone language. Or am I doing it wrong?
@andreyboytsov Can you confirm, that you are using "react-native-datepicker": "1.7.0" (or newer)? According to the release notes t was fixed in 1.7.0 - and it works like a charm here using <DatePicker locale={i18n.language}/>.
@jenskuhrjorgensen Thanks for getting back! "react-native": "0.55.4", "react-native-datepicker": "^1.7.2",
I'll try to come up with some small reproduction example.
Hi there,
React-native does not expose a locale param for Android: DatePickerAndroid So it always will be localized as the OS is.
On the other hand, iOS provides this feature: DatePickerIOS
So in Android it is not possible to overwrite the OS locale at native datepicker.
Hope it helps.
Wow, I didn't realize until now that you were talking about Android only! Sry for giving you false hope @andreyboytsov, but @pablo-albaladejo is absolutely right. Hopefully in another release someday soon 😄
OK.
@pablo-albaladejo @jenskuhrjorgensen Thanks for your assistance!
So, can someone tell when will we able to see locale support for Android? Thanks