Skip to content

Commit

Permalink
change localization documentation (#2064)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryD authored Apr 3, 2024
1 parent 8294c9b commit 0a36813
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions test-app/app/templates/docs/localization.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
## Localization
# Localization

flatpickr supports [over 25 languages](https://github.com/flatpickr/flatpickr/tree/master/src/l10n).

### Default Language
## Default Language

If you want to switch the default language for all flatpickr instances, you can do so by setting the language using the static flatpickr method localize:

```js
import flatpickr from 'flatpickr';
import lang from 'flatpickr/dist/l10n';

flatpickr.localize(lang.fr);
```

### Per-Instance Language
## Per-Instance Language

If you want to use a different language for a specific flatpickr instance, you can do so by passing the language to the `locale` option:
If you want to use a different language for a specific flatpickr instance, you can do so by passing the language to the `locale` option using a `string` or a `locale object` :

#### String locale

If you want to use a string to identify the locale, the lang file must be loaded in your app from `flatpickr/dist/l10n`:

```js
import 'flatpickr/dist/l10n/fr';
```
### String locale

```handlebars
<EmberFlatpickr
Expand All @@ -32,9 +27,9 @@ If you want to use a string to identify the locale, the lang file must be loaded
/>
```

#### Object locale
### Locale object

You can also pass a locale object to the `locale` option:
You can also pass a `locale object` imported from flatpickr to the `locale` option:

```js
import lang from 'flatpickr/dist/l10n';
Expand All @@ -52,9 +47,9 @@ You can also pass a locale object to the `locale` option:
/>
```

### Manual Localization Configuration
## Manual Localization Configuration

`locales` option also accepts an object for [custom locale configuration](https://chmln.github.io/flatpickr/#locale). This is useful for reusing app locale code.
`locales` option also accepts an object for [custom locale configuration](https://flatpickr.js.org/localization/#localization-in-a-browser-environment). This is useful for reusing app locale code.

The following example is using `moment.js` and assumes that a `userLocale` is specified to look up the correct locale configuration from `moment.js`.

Expand Down Expand Up @@ -93,4 +88,4 @@ export default class SomeController extends Controller {
/>
```

Check [flatpickr locale documentation](https://chmln.github.io/flatpickr/#locale) for a list of config options.
Check [flatpickr locale documentation](https://flatpickr.js.org/localization/) for a list of config options.

0 comments on commit 0a36813

Please sign in to comment.