From 5d092024bc16ca08c21a0f44ea94cbaba61bcb27 Mon Sep 17 00:00:00 2001 From: Carlos Vega Date: Thu, 24 Jan 2019 11:44:57 -0600 Subject: [PATCH 1/2] Added locale config for iOS DatePicker --- README.md | 1 + lib/templates/bootstrap/datepicker.ios.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 43cb5fed..36574096 100644 --- a/README.md +++ b/README.md @@ -565,6 +565,7 @@ The bundled template will render an iOS `UIDatePicker` component, but collapsed | `animationConfig` | The animation configuration object. Defaults to `{duration: 200}` for the default animation. | | `format` | A `(date) => String(date)` kind of function to provide a custom date format parsing to display the value. Optional, defaults to `(date) => String(date)`. | `defaultValueText` | An `string` to customize the default value of the `null` date value text. | +| `locale` | An `string` to set the locale for the component. | For the collapsible customization, look at the `dateTouchable` and `dateValue` keys in the stylesheet file. diff --git a/lib/templates/bootstrap/datepicker.ios.js b/lib/templates/bootstrap/datepicker.ios.js index 19958ced..eecc603e 100644 --- a/lib/templates/bootstrap/datepicker.ios.js +++ b/lib/templates/bootstrap/datepicker.ios.js @@ -71,6 +71,7 @@ class CollapsibleDatePickerIOS extends React.Component { } let formattedValue = locals.value ? String(locals.value) : ""; + let locale = 'en'; if (locals.config) { if (locals.config.format && formattedValue) { formattedValue = locals.config.format(locals.value); @@ -79,6 +80,9 @@ class CollapsibleDatePickerIOS extends React.Component { ? locals.config.defaultValueText : "Tap here to select a date"; } + if (locals.config.locale) { + locale = locals.config.locale; + } } const height = this.state.isCollapsed ? 0 : UIPICKER_HEIGHT; return ( @@ -105,6 +109,7 @@ class CollapsibleDatePickerIOS extends React.Component { onDateChange={this._onDateChange} timeZoneOffsetInMinutes={locals.timeZoneOffsetInMinutes} style={[datepickerStyle, { height: height }]} + locale={locale} /> From 8a34e38b312aa385e0409bbb4a91095d32e7aa40 Mon Sep 17 00:00:00 2001 From: Carlos Vega Date: Thu, 24 Jan 2019 12:38:30 -0600 Subject: [PATCH 2/2] Fixed double quote prettier issue --- lib/templates/bootstrap/datepicker.ios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templates/bootstrap/datepicker.ios.js b/lib/templates/bootstrap/datepicker.ios.js index eecc603e..4a1a104f 100644 --- a/lib/templates/bootstrap/datepicker.ios.js +++ b/lib/templates/bootstrap/datepicker.ios.js @@ -71,7 +71,7 @@ class CollapsibleDatePickerIOS extends React.Component { } let formattedValue = locals.value ? String(locals.value) : ""; - let locale = 'en'; + let locale = "en"; if (locals.config) { if (locals.config.format && formattedValue) { formattedValue = locals.config.format(locals.value);