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

Load only the needed datepicker i18n files instead of all #2553

Closed
ZeiP opened this issue Jan 5, 2021 · 2 comments · Fixed by #2650
Closed

Load only the needed datepicker i18n files instead of all #2553

ZeiP opened this issue Jan 5, 2021 · 2 comments · Fixed by #2650
Labels
bug 🐛 Problems with the code that result in unexpected or bad behavior Optimization 🏎 Go faster! User interface
Milestone

Comments

@ZeiP
Copy link
Member

ZeiP commented Jan 5, 2021

This was originally implemented in 4b046b9, but that broke when we upgraded to Sprocket 4 in 31af1a7. e1be3b8 fixed this temporarily by compiling in all languages, but this isn't a good solution – instead should find a way to define the jquery-ui/i18n/*.js to be compiled by Sprocket in app/assets/config/manifest.js.

The main difficulty with this is that the gems aren't in the application directory, but may be in /usr/local/bundle/gems or similar, and therefore the paths relative to the configuration file that Sprocket link definition supports doesn't work. The require definition can search from all paths (which also includes the jquery-ui-rails javascripts directory), so that's easier to do but it's not useful to load the localisations in all languages for each user.

@ZeiP
Copy link
Member Author

ZeiP commented Jan 13, 2021

I thought I tested this well, but apparently not. It seems to always provide the Russian translation for the widget, which is kinda suboptimal. This needs to be solved before next release.

@ZeiP ZeiP added this to the 2.5.1 milestone Jan 13, 2021
@ghost-from-the-past
Copy link

ghost-from-the-past commented Apr 13, 2021

If you end having the datepicker in russian like me (because the non respect of the local language setting) you can use this very dirty patch while waiting for the final solution.

The datepicker is using the last configuration line which is
//= require jquery-ui/i18n/datepicker-ru
in the file tracks/app/assets/javascripts/applications.js

I edited the file and added after the russian one
//= require jquery-ui/i18n/datepicker-en-GB

if the language you want is already in the list, just move it to the end of the list.

In my case there was no english line but I checked and they are present at directory
/var/lib/gems/2.7.0/gems/jquery-ui-rails-6.0.1/app/assets/javascripts/jquery-ui/i18n
en-AU, en-GB, en-NZ so was safe to add the en-GB

(I use plain server, Apache , no docker)
I recompiled
bundle exec rake assets:precompile RAILS_ENV=production
adjusted the file access rights
and restart the webserver
systemctl restart apache2

now the dates are in english and I can survive until the correct solution is pushed

Regards

@ZeiP ZeiP added bug 🐛 Problems with the code that result in unexpected or bad behavior and removed Enhancement ⚡️ New features, big or small. labels Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Problems with the code that result in unexpected or bad behavior Optimization 🏎 Go faster! User interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants