chinleung / laravel-multilingual-routes

A package to handle multilingual routes in your Laravel application.
https://github.com/chinleung/laravel-multilingual-routes-demo
MIT License
395 stars 25 forks source link

Support for Group Routes and "espanol" as locale #17

Closed abdulwahid closed 4 years ago

abdulwahid commented 4 years ago

I have two questions.

  1. Does this provide support for grouped routes?
  2. Is there a way to have espanol as locale instead es

E.g I want to have following routes:

EN Routes:

/blog/abc
/blog/mno
/blog/xyz

ESPANOL Routes:

espanol/blog/abc
espanol/blog/mno
espanol/blog/xyz

For using espanol, i can do it by using espanol instead of es altogether throughout the project but this make me use espanol as locale key instead of es. I can add locales in config/app.php 'locales' => ['en' => 'English', 'espanol' => 'Espanol'] So instead of resource/lang/es I would need to do like this: resource/lang/espanol

What i want is to have some mapper for using es as locale key instead of espanol.

@chinleung Any help will be much appreciated.

chinleung commented 4 years ago

Does this provide support for grouped routes?

I'm not sure to understand this question. It is possible to achieve the three routes in your example with the locale key at the moment. So it would be:

es/blog/abc
es/blog/mno
es/blog/xyz

Otherwise the locale key would have to be espanol.

Is there a way to have espanol as locale instead es

Yes like you mentioned, you can do:

'locales' => [
    'en' => 'English',
    'espanol' => 'Espanol',
],

Could you explain what's the use case of having both mixed? Like why you want es as locale key, but use espanol at other places?

It would be possible to add a config for mapping the route prefixes of the locale, but I'm just trying to understand the utility first.

abdulwahid commented 4 years ago

It was just the requirement to have espanol in routes, i just wanted to use es as locale key internally to follow conventions. However i have fixed the issue by using espanol as locale key.