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

Routing name has locale suffix #329

Closed
rjwebdev opened this issue Jun 20, 2018 · 7 comments
Closed

Routing name has locale suffix #329

rjwebdev opened this issue Jun 20, 2018 · 7 comments

Comments

@rjwebdev
Copy link

I recently updated my Symfony application to 4.1 so I can use the new internationalized routing feature.

When I dump the exposed routes to a javascript file, 2 routes are generated, having the locale of the path as suffix. For example I have a route app.user.index with following paths:

  • en: /users
  • fr: /utilisateurs

In my generated file, I have to routes app.user.index.en and app.user.index.fr

@stof
Copy link
Member

stof commented Jun 20, 2018

yeah, having 2 routes is how the Symfony 4.1 feature works internally (and Symfony tries to generate the locale-specific variant first).

the route generator in this bundle is not yet updated to support the same feature.

@rjwebdev
Copy link
Author

rjwebdev commented Jun 21, 2018

Do you have any idea when this feature will be supported?

I already worked out an idea myself but I'm not sure if it is a good one:
You can define a variable in javascript that contains the Symfony request locale. Then you can add this value to the prefixedName variable in the 'getRoute' function.

@stof
Copy link
Member

stof commented Jun 21, 2018

The only answer I can give you is "when someone works on it". that's how open-source work when everyone is working on it on their free time (and I'm not using this bundle myself anymore since a long time, so it may not even be my priority on my free time)

@rjwebdev
Copy link
Author

Is it possible to get some more info/input from someone who is still maintaining this bundle?

@rjwebdev
Copy link
Author

@stof

Any news on this issue so far?

@Padam87
Copy link

Padam87 commented Mar 21, 2019

Probably the simplest way to work around this

const locale = $('body').data('locale');
const RoutingDecorator = {
    generate: function (name, params) {
        const orig_name = name;

        try {
            Routing.getRoute(name)
        } catch(error) {
            name = name + '.' + locale;

            try {
                Routing.getRoute(name)
            } catch(error) {
                name = orig_name;
            }
        }

        return Routing.generate(name, params);
    }
};

@tobias-93
Copy link
Collaborator

This is now supported since #334 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants