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

[5.3] Resource routes uri translations #16429

Merged
merged 1 commit into from
Dec 7, 2016

Conversation

shadoWalker89
Copy link
Contributor

@shadoWalker89 shadoWalker89 commented Nov 16, 2016

The PR allows to define the slug for resource routes.

Route::uriTranslations([
    'create' => 'ajouter',
    'edit' => 'modifier'
]);

Now when a resource foo is added the uri for create and edit will be

foo/ajouter
foo/{foo}/modifier

Why need this ?

When building applications for non english speakers, they always ask why the urls are in english ?, and in many cases they require them to be in the application language (which is french for me)

So what i end up doing is using resource() for every thing except create and edit which i add manually.
It become a pain and clutters the routes file.

This PR try to solve that by adding the possibility to customize the slugs used for create and edit routes

@shadoWalker89 shadoWalker89 changed the title [5.3] Resource routes url translations [5.3] Resource routes uri translations Nov 16, 2016
@fernandobandeira
Copy link
Contributor

fernandobandeira commented Nov 17, 2016

This is indeed nice but using a method to define the translations look's so bad IMHO. I bet that we could come up with a better solution for this, IK why you did it this way though...

@shadoWalker89
Copy link
Contributor Author

@fernandobandeira I did it this way, because i don't want to over complicate things.

If it were for me, i would never change urls, but there is clients that require the urls to be in french or whatever language they speak, and frankly i don't blame them.

This is the simplest way i could think of and it's similar to how $parameterMap is handled, but i'm open for suggestions.

@garygreen
Copy link
Contributor

garygreen commented Nov 18, 2016

I like this though not so much it's implementation (particularly the word translation). I'd prefer something like:

Route::resourceUrls([
    'create' => 'ajouter',
    'edit' => 'modifier'
]);

Also no way this can go into 5.3, it should be 5.4.

@shadoWalker89
Copy link
Contributor Author

@garygreen Yeah using Urls is a good alternative. Let's wait for @taylorotwell decision.
About the branch, this is not a breaking change and neither a major feature, so it could go 5.3 (frankly i hope if it's merged, it will be on 5.3 because i need it now :D)

@garygreen
Copy link
Contributor

Sure, not a breaking change but a feature like this shouldn't go as a patch version imo. Obvs up to Taylor anyway

@taylorotwell taylorotwell merged commit e9cb492 into laravel:5.3 Dec 7, 2016
@taylorotwell
Copy link
Member

Route::resourceVerbs($verbs)

@shadoWalker89 shadoWalker89 deleted the resource_route_translation branch December 8, 2016 08:17
@garbinmarcelo
Copy link

@shadoWalker89 @taylorotwell Does this still work in version L5.5? I'm not getting it to work, but version L5.4 work's.

@garbinmarcelo
Copy link

Sorry, I was putting the function in RouteServiceProvider instead of AppServiceProvider .. It's working ..

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

Successfully merging this pull request may close these issues.

None yet

5 participants