Skip to content

Commit

Permalink
Merge pull request mui#3024 from oliviertassinari/date-picker-fr
Browse files Browse the repository at this point in the history
[Docs] Move DateTimeFormat polyfill to the example
  • Loading branch information
alitaheri committed Jan 24, 2016
2 parents 733abf4 + 18d8a4c commit 0e58efb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"history": "1.13.x",
"html-webpack-plugin": "^1.6.1",
"intl": "^1.0.1",
"intl-locales-supported": "^1.0.0",
"json-loader": "^0.5.4",
"marked": "^0.3.5",
"raw-loader": "^0.5.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import React from 'react';
import DatePicker from 'material-ui/lib/date-picker/date-picker';
import areIntlLocalesSupported from 'intl-locales-supported';

let DateTimeFormat;

// Use the native Intl if available
if (areIntlLocalesSupported('fr')) {
DateTimeFormat = global.Intl.DateTimeFormat;
} else {
const IntlPolyfill = require('intl');
require('intl/locale-data/jsonp/fr');

DateTimeFormat = IntlPolyfill.DateTimeFormat;
}

const DatePickerExampleInternational = () => (
<DatePicker
hintText="fr version"
DateTimeFormat={Intl.DateTimeFormat}
DateTimeFormat={DateTimeFormat}
// Intl is supported by most modern browsers, see http://caniuse.com/#search=intl
// for browsers that don't support it use this polyfill https://github.com/andyearnshaw/Intl.js
wordings={{ok: 'OK', cancel: 'Annuler'}}
Expand Down
5 changes: 0 additions & 5 deletions docs/src/app/components/pages/components/DatePicker/Page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ const descriptions = {
'Note that the buttons must be localised using the `wordings` property, and we set the `firstDayOfWeek` to Monday.',
};

if (!window.Intl) {
require('intl');
require('intl/locale-data/jsonp/fr');
}

const DatePickerPage = () => (
<div>
<MarkdownElement text={datePickerReadmeText} />
Expand Down

0 comments on commit 0e58efb

Please sign in to comment.