Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup localization documentation #2064

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading