Problem/Motivation
Summary
This functionality used to exist in jquery_ui 1.x via jquery_ui_datepicker 1.x.
This issue was raised in order to bring back this functionality into jquery_ui 2.x.
The jquery_ui_datepicker module used to have translations via the drupal ui, please see merge request 10 that restores this functionality.
First pass at making i18n work concludes it only works in one language , my first attempt at patching jquery_ui resulted in a one language for all, choose that language and unable to switch between translations.
Current status
- Merge request 10 restores the expected functionality.
No localisation for datepicker - Merge request 10 restores the expected functionality.
No Drupal.t support (our preferred approach) - Merge request 10 restores the expected functionality.
No jquery_ui i18n/ i18n folder is missing (better than nothing approach uses browser preference not Drupal)
Thank you to bnjmnm for restoring this functionality. prefer the approach used in the jquery_ui_datepicker 1.x release.
@Gábor Hojtsy ,
In the jquery_ui_datepicker 1.x branch the months, weeks and days were translated using Drupals t() function. This allows the date calendar weeks/days/months labels to match the language of the Drupal interface language rather than using the jquery_ui approach of loading the calendar language based on the browsers declared locale which stays the same on any Drupal translation. So if your locale is english you'll see an English calendar on a french or german translation. We prefer the calendar matches the Drupal interface language. However jquery_ui currently doesn't even have ANY locales, there's no i18n folder , no locales at all so we get zero locales except English.
The jquery_ui_datepicker 1.x approach is desireable to us because it uses Drupals t() function for weeks, months, labels and respects the interface language for the current page and we like this approach. However the jquery_ui_datepicker 2.x branch is an empty shell, and relies 100% on the jquery_ui module to do the datepicker and the jquery_ui module does neither offer the i18n versions of the jquery datepicker nor does it use the t string approach that the 1.x jquery_ui_datepicker module used.
So basically if you use jquery_ui simultaneously with the 2.x branch of the jquery_ui_datepicker module then you have no localisation for the datepicker. The 2.x branch of the jquery_ui_datepicker is basically offloading everything to jquery_ui and whoever published the jquery_ui_datepicker 2.x branch gutted everything from 1.x in favour of some new approach which lacks localisation.
This is the shortenned summary of the situation.
Here is what we expect:

Here is what jquery_ui module gives us instead:

So in addition to having no translation at all is that the default jquery_ui solution (even if it was implemented) normally relies on the browser language rather than the Drupal interface language. jquery_ui_datepicker 1.x solves all of this. See the source code for jquery_ui_datepicker how it uses Drupals t functions for the labels.
So I've downgraded to jquery_ui_datepicker 1.x latest and jquery_ui_effects 1.x latest and am using patches to upgrade the library to 1.13.2
This resolves the issue for D9, but it will likely become a problem in D10 if we're forced to use the new approach.
Motivation
We need the date picker to work in our language but jquery_ui module does not include the assets/vendor/jquery.ui/ui/i18n folder
tested this approach, the hook being used runs only once per cache rebuild. I'm not sure where to intercept the library on page load and load the expected i18n js file. I was only able to hack in my chosen language over top of all others.
Steps to reproduce
Proposed
a dirty solution is to add the jquery ui i18n folder but would prefer drupal t strings, with that said, i18n folder is going to work we can deal with improvements later this should be adequate.
Tested this approach and it doesn't work as expected, can only override english with one other language and then english is lost
reproduce:
install jquery_ui, visit the date picker using a drupal interface language OTHER than english
the months and days show up in ENGLISH only. So far patching has only permitted substituting english with one language and then stuck with that one language choice.
Proposed resolution
Include the i18n folder with all the languages
Remaining tasks
write a patch and review
User interface changes
expected labels for months and days should show up
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #49 | jquery_ui-3339013-49.patch | 3.33 KB | joseph.olstad |
| #44 | jquery_ui-with_datepicker_after.png | 18.83 KB | joseph.olstad |
| #44 | jquery_ui-datepicker_before_fix.png | 18.95 KB | joseph.olstad |
| #37 | jquery_ui-localize_date_picker-3339013-37.patch | 123.6 KB | cgoffin |
| #36 | jquery_ui-localize_date_picker-3339013-36.patch | 137.39 KB | cgoffin |
Issue fork jquery_ui-3339013
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joseph.olstadComment #3
joseph.olstadsee patch, there's likely a composer way to do this that would be better.
this is for a quick win.
Comment #4
joseph.olstadnew patch, french only, patch 3 is not working
Comment #5
joseph.olstadComment #6
joseph.olstadComment #7
joseph.olstadnew patch
Comment #8
joseph.olstadnew patch
Comment #9
joseph.olstadOk so this hook has a limitation in that it only runs once even if you switch languages.
I haven't found an alternative, just throwing this patch up there for those that prefer any language other than English to show up in the date picker.
Comment #10
joseph.olstadpatch 9 wasn't good, this one will force another language other than English, same limitation, this hook only runs once regardless of the language being loaded.
Comment #11
joseph.olstadComment #12
joseph.olstadok patch 10 didn't work, but patch 12 should force another language other than English, same limitation, this hook only runs once regardless of the language being loaded.
This approach will only help those who are supporting one language other than english.
Comment #13
joseph.olstadjquery_ui ui/i18n folder is missing, no translations available
Comment #14
joseph.olstadComment #15
joseph.olstadComment #16
joseph.olstadComment #17
joseph.olstadComment #18
joseph.olstadpatch 12 is a hack that forces a different language makes it consistently that language.
Comment #19
gábor hojtsyYou clearly seem to know this area very well. Can you summarize how it worked before and how it works (or does not work) now, so it can be seen by people reading the issue what are the incompatibilities?
Comment #20
joseph.olstad@Gábor Hojtsy ,
In the jquery_ui_datepicker 1.x branch the months, weeks and days were translated using Drupals t() function. This allows the date calendar weeks/days/months labels to match the language of the Drupal interface language rather than using the jquery_ui approach of loading the calendar language based on the browsers declared locale which stays the same on any Drupal translation. So if your locale is english you'll see an English calendar on a french or german translation. We prefer the calendar matches the Drupal interface language. However jquery_ui currently doesn't even have ANY locales, there's no i18n folder , no locales at all so we get zero locales except English.
The jquery_ui_datepicker 1.x approach is superior because it uses Drupals t() function for weeks, months, labels and respects the interface language for the current page. However the jquery_ui_datepicker 2.x branch is an empty shell, does nothing and relies 100% on the jquery_ui module to do the datepicker and the jquery_ui module does neither offer the i18n versions of the jquery datepicker nor does it use the t string approach that the 1.x jquery_ui_datepicker module used.
So basically if you use jquery_ui simultaneously with the 2.x branch of the jquery_ui_datepicker module then you have no localisation for the datepicker. The 2.x branch of the jquery_ui_datepicker is basically an empty shell offloading everything to jquery_ui and whoever published this branch gutted everything from 1.x.
This is the shortenned summary of the situation.
Here is what we expect:
Here is what jquery_ui module gives us instead:
So in addition to having no translation at all is that the default jquery_ui solution (even if it was implemented) normally relies on the browser language rather than the Drupal interface language. jquery_ui_datepicker 1.x solves all of this. See the source code for jquery_ui_datepicker 1.x branch for how it uses Drupals t functions for the labels.
Comment #21
joseph.olstadSo I've downgraded to jquery_ui_datepicker 1.x latest and jquery_ui_effects 1.x latest and am using patches to upgrade the library to 1.13.2
This resolves the issue for D9, but it will likely become a problem in D10 if we're forced to use the new approach.
Comment #22
joseph.olstadComment #23
joseph.olstadComment #24
joseph.olstadComment #25
bnjmnmHey! I'm sure it's frustrating to run into this kind of thing.
This issue is also making several bad faith assumptions, and throwing "inferior" into the issue title is just rude.
The work done to make this suite of modules Drupal 10 ready was not done by me, but I think it is really clever work! The approach removes the need to coordinate updates across 16+ modules, accounts for assets that may still be present on core, and was designed to be minimally disruptive.
The issue you're experiencing here is *one* thing that slipped through that enormous effort because datepicker + core has an additional edge case that requires an additional bit of logic. It was truly easy to overlook considering is was a need unique to one library among many, many libraries. The comments on this seems to presume it was somehow malicious or an intentional inconvenience? Nah. Just a tiny thing overlooked in a huge undertaking.
Again, I understand the frustration, but this coming on a little hot, yea?
I have a patch that fixes this just sitting on my hard drive ready to upload, but it can wait until the tone here is a little more respectful of the people that worked hard (and 99.9 percent succeeded) to provide a solution that is manageable in the long term.
Comment #26
bnjmnmI remembered that ultimatums are not my style, and also realized that I'd be denying this fix to other users if I made this conditional on seeing a bit of civility. The patch is attached, but I sure wish this was brought to our attention with a little less 🖕 and a little more 🤝. Understanding the issue required wading through an unfortunate amount of grouchin' here and elsewhere.
The attached patch fixes it for me. This is the one place (to the best of my knowledge) where jQuery UI assets were not specified in core.libraries.yml, and I imagine that's why it was unintentionally omitted from the earlier release.
Comment #27
joseph.olstad@bnjmnm, thanks for the patch and for your extensive Drupal works, it looks good.
It appears that you've managed to bring in the locale.js approach that looks similar to the jquery_ui_datepicker solution (we prefer this approach). Perhaps making the i18n folder is optional at this point? Maybe a configuration option for the approach, so that those that want to use the Drupal.t string approach can use it exclusively.
I haven't had a chance to test it yet but will make an effort to do so as soon as possible and provide useful feedback.
For now we've got the 1.13.2 update with jquery_ui_datepicker with the 1.x branch.
Thanks again for the quick reply, I was expecting to have to do this by myself in 6 months from now when we start getting more serious about D10. So it is encouraging to have such a quick solution. I look forward to testing it.
Comment #28
joseph.olstadComment #29
joseph.olstadComment #30
joseph.olstadDefinately some great work on patch #26, I will attempt to draw attention to this from somewhat related issues that are open.
Comment #31
joseph.olstadComment #32
joseph.olstadPatch 26 works well, testing it some more again today, it works well thank you
Comment #33
joseph.olstadalthough I did upgrade simultaneously to the webform 6.2.x module and the webform 6.2.x module comes with the webform_jquery_ui_datepicker module so maybe there's some help from that module, my webform date pickers had the expected language calendar when using patch 26.
I'll have to re-test without patch 26 again .
Comment #36
cgoffin commentedNice job adding the localization js files. I extended this by loading the correct js for the active language (a little bit based on how ckeditor5 does it). Here also an updated patch file.
Comment #37
cgoffin commentedThere were some encoding issues in the translation files. Here also a new patch.
Comment #38
cgoffin commentedIt seems the upload of the patch file changes the encoding. No idea how to fix this. But in the fork the encoding seems good.
Comment #39
aelfendir commentedPatch #26 worked well. Fantastic work, thank you!
Comment #40
aimadbachar commentedHi
Patch #26 woked well too, Now I can switch between English and other languages; the translation works well on the datepicker
Thanks
Comment #41
joseph.olstadOther than patch 26, you could also try the merge request patch:
https://git.drupalcode.org/project/jquery_ui/-/merge_requests/10.patch
Comment #42
joseph.olstadMR 10 works well in french and english mode. The calendar follows the language of the page being loaded. So when I load the translated page (English) it shows up in English, when I load the original source language (French) the calendar days and months show up in French.
Comment #43
joseph.olstadpatch is still needed now that to use D10 we can no longer use the previous releases of the modules involved that had this working in D9.
So I'll mark this as RTBC for merge request 10.
Comment #44
joseph.olstadBefore patching:

After patching with MR 10 and rebuilding cache, no special settings were used, the js/locale.js is doing the work here, not the assets/vendor/jquery.ui/ui/i18n/datepicker*.js as that setting was not activated (nor needed).
MR 10 patch used:
https://git.drupalcode.org/project/jquery_ui/-/merge_requests/10.patch
Notice how in the before screenshot the weekdays are showing up in English (Mo, Tu, We, Th, Fr, Sa, Su) and the month shows up Feb.
After patching the expected French language days of week is loaded. (Lu, Ma, Me, Je, Ve, Sa, Di) and month abbreviation is correct as "Fév"
We do have an english version of this particular instance, the calendar still functions in English as expected after applying the patch.
Comment #45
joseph.olstadComment #46
mazz0016 commented@joseph.olstad Thanks for the fix! Went looking for this to fix WCAG issues and found that you have already resolved it. The web team thanks you! Great work!
Comment #47
joseph.olstadActually, all the props go to @bnjmnm , he wrote the new patch that fixes this, I may have re-rolled it.
but ya, important fix!
Comment #48
smulvih2I was banging my head trying to get the date-picker translated into French. Then @joseph.olstad suggested I try patch #26 and it worked! We should really get this patch rolled into a release so anyone using this module on a multilingual site will have proper translations for the date-picker!
+1 RTBC
Comment #49
joseph.olstadI've forked jquery_ui into a new project called jq_ui
This project jq_ui is a drop in replacement for jquery_ui.
For those that do not wish to use a patch, simply replace jquery_ui as follows (drop in replacement).
composer require drupal/jq_uiWith that said, I'll do the community type thing to do, provide a simpler, functional solution to any of those previously proposed above. This patch attached is for jquery_ui.
Comment #51
joseph.olstadDiff from MR 22:
https://git.drupalcode.org/project/jquery_ui/-/merge_requests/22.diff
For those of us who are no longer going to wait another eternity for a release with a fix, a release of jq_ui is available now, this is an easy drop-in replacement for jquery_ui that I am now promoting.
Comment #52
joseph.olstadhttps://www.drupal.org/project/jq_ui
Steps to replace jquery_ui:
Step 1)
composer require drupal/jq_uiStep 2)
drush en jq_ui -y;Step 3)
drush cr;Step 4) Sip from a marguerita
How is this possible you might ask? composer replace!
Comment #53
joseph.olstadAnd here it is: On a silver platter for everyone!
https://www.drupal.org/project/jq_ui/releases/8.x-1.7
Comment #55
joseph.olstadMR 10 has a lot of unneeded code.
MR 22 provides a solution and only has minimal changes to three files.
Comment #56
rajeshreeputra@joseph.olstad - changes in MR!22 look good. Once the PHPCS warnings are fixed, we can proceed with the merge by this weekend.
Comment #57
joseph.olstadphpcs is passing with MR 22
@rajeshreeputra , appreciate your attention to this!
Comment #59
rajeshreeputraComment #61
joseph.olstad@rajeshreeputra, michel.g pointed out something we missed here. I'll push it up now.
Comment #63
joseph.olstad@rajeshreeputra,
Please review the merge request.
Relates to work done for the jq_ui "replace" jquery_ui project by @michel.g that we should bring into jquery_ui.
#3545944: locale.js should depend on core/jquery
Comment #68
rajeshreeputraMerged MR!23.
Comment #70
joseph.olstad@rajeshreeputra, please add credit to michelg. It was michelg that pointed this out in the related issue but he hasn't been credited here for the solution.
https://drupal.org/u/michelg
Comment #71
joseph.olstad@rajeshreeputra, please tag a new release for jquery_ui , it has been approximately 18 months since a tagged release!
Comment #72
rajeshreeputra8.x-1.8 is the new tag.
Comment #73
joseph.olstad@rajeshreeputra, I see you tagged 8.x-1.8 (Thank you), however you may have forgotten to create the release build , I still see 1.7 on the project page.
Comment #74
rajeshreeputraohhh, yes, updated.
Comment #75
joseph.olstad@rajeshreeputra, thank you very much!