chinleung / laravel-multilingual-routes

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

Default route is not defined #46

Closed mvneobux closed 3 years ago

mvneobux commented 3 years ago

My default home page route should be "en-us". However it is not working at all. When I try to access the route I get a 404 error. See:

My route: Route::multilingual('/cadastrar', 'CadastroController@index')->name('cadastrar');

Configuration file:

return [

    'default' => env('MULTILINGUAL_ROUTES_DEFAULT_LOCALE', config('app.locale')),

    'prefix_default' => env('MULTILINGUAL_ROUTES_PREFIX_DEFAULT', true),

    'prefix_default_home' => env('MULTILINGUAL_ROUTES_PREFIX_DEFAULT_HOME', true),

    'name_prefix_before_locale' => env('MULTILINGUAL_ROUTES_NAME_PREFIX_BEFORE_LOCALE', false),
];

Config App:

'locale' => 'pt-br',

Because it does not work ?? if I change the locale to "en" then it works, but as "pt-br" it doesn't

chinleung commented 3 years ago

Hi @mvneobux,

You need to setup a locales config in your config/app.php or publish the config file for the locales: https://github.com/chinleung/laravel-locales#configuration.

I've setup a working example that contains the following routes:

+--------------------+-----------------+
| URI                | Name            |
+--------------------+-----------------+
|                    | en.home         |
| /pt-br             | pt-br.home      |
| pt-br/cadastrar    | pt-br.register  |
| pt-br/teste        | pt-br.test      |
| pt-br/users/{user} | pt-br.user.show |
| register           | en.register     |
| test               | en.test         |
| users/{user}       | en.user.show    |
+--------------------+-----------------+

Let me know how it goes. 😄

mvneobux commented 3 years ago

Thanks :)