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?
Hi @proweb ,
You can translate Flatpickr by following these steps:
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') );
} );
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.
Most helpful comment
Hi @proweb ,
You can translate Flatpickr by following these steps:
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') ); } );php ->set_picker_options( array( 'locale' => 'ru', ) ),I've also just pushed an update to
developmentwhich 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).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.