FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

JS-routing + JMS i18n bundle #221

Open jdeniau opened 8 years ago

jdeniau commented 8 years ago

Hi,

Before I make a PR, I have some questions about the usage of jsrouting and jms i18n routing:

I saw that you provide a "locale" option, wich added a value in the "prefix" key. This prefix is added to the route name if no route matches the wanted route. (if I understand it well).

JMS routing prefixes the routes likes this: foo route become : fr__RG__foo and en__RG__foo.

I do not quite well understand the RG part, but it may not be important.

If I understand well the two packages (that I am not sure), the locale parameter of the fos:js-routing:dump command must be fr__RG__ or en__RG__.

First of all, if I'm right, I will make a PR on the doc to explain this, because at first, I though that the locale parameter must be fr on en.

Secondly, the generated JSON contains all the routes, with all the différents locale. Is there a reason to do this ?

Because you make you client download every routes in every locale, which is not efficient.

Can we remove all routes which did not start by the "prefix" ? If so, I saw too that routes may be untranslated, so we have to keep them, but the pattern to exclude seems quite easy too (^([a-z]{2})__RG__ or something like that).

If you do not see a problem with this, I will make another PR, but as I do not see the whole picture here, I may be wrong. Maybe it would be an idea to add an option to filter the non matching routes ?

Thank you

Mrkisha commented 7 years ago

This is still an issue. Any fix?

webjaros commented 7 years ago

+1 for "prefix" solution.

JMSI18nRoutingBundle allows using just route title without locale prefix in router generation on backend side (i.e. in twig template). It seems to be logical to make this work the same on frontend side.

tobias-93 commented 6 years ago

Is this still an issue for version 2.0.0 of the bundle?

hectorj commented 6 years ago

Still a problem for me with friendsofsymfony/jsrouting-bundle: 2.2.0 and jms/i18n-routing-bundle: 2.0.4

tdaws commented 6 years ago

I have also run into this issue. It appears that when js/fos_js_routes.js is compiled via assetic, you get the route names with the prefixes as described above, but if the js file is loaded directly without assetic, it will work as expected for the default language.