laravel-localization icon indicating copy to clipboard operation
laravel-localization copied to clipboard

Prefix support

Open insp3 opened this issue 8 years ago • 12 comments

Hello

Please add prefix support. Like for b2b site:

www.example.com/b2b/en/

insp3 avatar Dec 12 '16 12:12 insp3

u can do it on ur own by simply wrapping all in a route prefix

Route::group(['prefix' => 'b2b'], function () {
    // all ur routes goes in here
});

https://laravel.com/docs/5.3/routing#route-group-prefixes

ctf0 avatar Jan 04 '17 00:01 ctf0

Thank you for your response. I know how prefixes works.

If i just wrap and use localization then url will be redirected to: www.example.com/en/b2b/ but i want www.example.com/b2b/en/

It looks more natural and right.

insp3 avatar Jan 04 '17 08:01 insp3

@mcamara i think we can add a new config for this so it gets prepended to the locales

ctf0 avatar Jan 04 '17 10:01 ctf0

If we can define in config file our prefixes where we like to use localization then it will be create. Like in array ['b2b', 'admin', 'etc']. Its simple enough.

insp3 avatar Jan 04 '17 15:01 insp3

i dont think its possible to have an array, cuz now you will need to have somthing that define which prefix you want to use at which time/case

ctf0 avatar Jan 04 '17 15:01 ctf0

I can't figure out how to wrap route group that already has a prefix, say 'admin', with localization. Can anyone tell me how, please?

arquadrado avatar Jun 26 '17 14:06 arquadrado

I think i and arquadrado are not the only one who needs this prefix support.

insp3 avatar Jul 31 '17 10:07 insp3

in www.example.com/b2b/en/ to get 'en' just App::setLocale($request->segment(2));

MohamedSR avatar Aug 24 '17 15:08 MohamedSR

Any update on this issue yet? I'm having the same problem for a site completely deployed behind another site's sub-path. Thanks

satvheck avatar Jan 22 '18 21:01 satvheck

Same issue here.

fpalamour avatar Apr 30 '18 07:04 fpalamour

Same issue here , I want to get Additional Prefix Parameter dynamically from database and language as it is , if any update please let me know Sir.

AbdulBasit510 avatar Jul 14 '18 06:07 AbdulBasit510

This is still not possible. PR are welcome, though it will be hard, because one would have to changed quite a lot of the package to add such a feature. The rule that the language parameter is the first parameter of the url is hardcoded in the LaravelLocalization model, in the redirect middleware and in the caching functionality. One would basically need to rewrite every model, middleware, trait and many tests in order to archive that.

Also, from a SEO perspective, its it recommended to have the locale as first parameter in the url: https://support.google.com/webmasters/answer/182192

Maybe its easier for you to create subdomains, like admin.yourdomain.com/en/ and guest.yourdomain.com/en/ this would work out of the box with this package.

iwasherefirst2 avatar Oct 19 '19 22:10 iwasherefirst2