UserFrosting
UserFrosting copied to clipboard
Load the correct `jquery-validation` locale.
If no message is defined in the validation schema, the default english locale from jquery-validation
widget is displayed. The appropriate locale should be loaded instead.
The problem is how to load the correct locale since the assets are defined in a bundle... That, or we load every locale and use a setLocale
method (if they support any).
Actually, we could also generate the appropriate js file dynamically : https://stackoverflow.com/a/2457053/445757
Seems like we need to have a broader discussion on client-side i18n.
A lightweight solution to this specific scenario would be to work it out in Twig (perhaps with a helper method or 2), and add the applicable translation script right under {{ assets.js() | raw }}
.
A lot of client-side packages can actually detect a target language specified in the DOM; see for example Select2's i18n support.
So the work you've done for #718 could actually help resolve this, at least for some packages.
If that's the case, then I thinking we pass the resolved set of languages to the frontend, and let some JS figure things out. Suppose we should adhere to the specs as well as we can here, so the html
lang
attribute should contain the first preference, and if there are more, have a comma delimited list in the Content-Language
header of the response.
Sounds like a good place to start.