Carbon-fields: Localisation for flatpickr

Created on 3 Dec 2017  路  3Comments  路  Source: htmlburger/carbon-fields

In Date, Date Time and Time field Carbon Fields uses flatpickr


Do we have localization part of flatpickr in carbon fields?
If not, would it be included in future versions?

And which is the right way to add localisation (for example Russian) for actual version of Carbon fields?

enhancement [status] fixed in dev

Most helpful comment

Hi @proweb ,

You can translate Flatpickr by following these steps:

  1. Add the following to your functions.php:
    php add_action( 'admin_enqueue_scripts', function() { wp_enqueue_script( 'flatpickr-locale-ru', 'https://npmcdn.com/flatpickr/dist/l10n/ru.js', array('carbon-fields-boot') ); } );
  2. Add the following to the date/time/datetime field definition:
    php ->set_picker_options( array( 'locale' => 'ru', ) ),

I've also just pushed an update to development which will make step 2 optional (the locale will be passed to Flatpickr automatically but can be overriden) and added relevant help text in the docs (changes will be reflected on next release).

And which is the right way to add localisation (for example Russian) for actual version of Carbon fields?

Carbon Fields already include Russian translation files that will be automatically used if your administration language is set to Russian. If you notice any untranslated or incorrectly translated strings feel free to modify the languages/carbon-fields-ru_RU.* files and submit a pull request with the changes.

All 3 comments

Hi @proweb ,

You can translate Flatpickr by following these steps:

  1. Add the following to your functions.php:
    php add_action( 'admin_enqueue_scripts', function() { wp_enqueue_script( 'flatpickr-locale-ru', 'https://npmcdn.com/flatpickr/dist/l10n/ru.js', array('carbon-fields-boot') ); } );
  2. Add the following to the date/time/datetime field definition:
    php ->set_picker_options( array( 'locale' => 'ru', ) ),

I've also just pushed an update to development which will make step 2 optional (the locale will be passed to Flatpickr automatically but can be overriden) and added relevant help text in the docs (changes will be reflected on next release).

And which is the right way to add localisation (for example Russian) for actual version of Carbon fields?

Carbon Fields already include Russian translation files that will be automatically used if your administration language is set to Russian. If you notice any untranslated or incorrectly translated strings feel free to modify the languages/carbon-fields-ru_RU.* files and submit a pull request with the changes.

big thanks @atanas-angelov-dev Great support as always =)

2.2.0 is now live which addresses this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Roman52 picture Roman52  路  3Comments

leurdo picture leurdo  路  3Comments

ArekZw picture ArekZw  路  4Comments

halvardos picture halvardos  路  4Comments

Mick00 picture Mick00  路  3Comments