UserFrosting icon indicating copy to clipboard operation
UserFrosting copied to clipboard

Load the correct `jquery-validation` locale.

Open lcharette opened this issue 7 years ago • 6 comments

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).

lcharette avatar Jul 02 '17 03:07 lcharette

Actually, we could also generate the appropriate js file dynamically : https://stackoverflow.com/a/2457053/445757

lcharette avatar Jul 02 '17 04:07 lcharette

Seems like we need to have a broader discussion on client-side i18n.

alexweissman avatar Jul 09 '17 20:07 alexweissman

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 }}.

Silic0nS0ldier avatar Dec 14 '17 11:12 Silic0nS0ldier

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.

alexweissman avatar Dec 20 '17 16:12 alexweissman

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.

Silic0nS0ldier avatar Dec 21 '17 01:12 Silic0nS0ldier

Sounds like a good place to start.

alexweissman avatar Dec 21 '17 02:12 alexweissman