Closed simplenotezy closed 6 years ago
Something like this may work (not tested):
Route::get('/' . _('about-us'), function(){
...
});
Please let me know if it does
If I have the following route:
Route::get('/' . _('Classes'), function() {
echo 'hi ' . _('Classes');
});
I can only access it through "Classes", but when I hit the route, it will show the translated string of "Classes".
You didn't change current locale before calling "Route::get".
@ihoru true, but what does that change?
True, following works:
\LaravelGettext::setLocale('da_DK');
Route::get('/' . _('Classes'), function() {
echo 'hi ' . _('Classes');
});
But I guess the way the package is setup is to be set through middleware, right?
Translatable routes is something that could make this package really strong IMO. The biggest difficulity right now, as I see it, is a clean & proper way to translate routes, and the option to choose between two main setups:
Setup 1 (prefix): http://domain.com/en/about-us
Setup 2 (subdomain): http://en.domain.com/about-us
With the posibility of having the prefix/subdomain optional for the default language: http://domain.com/about-us (for english).
This package is about it, regarding prefix: https://github.com/mcamara/laravel-localization but really lacks a posibility to have setup 2 with optional default language.
I think a solution could be some kind of regular expression constraits: https://laravel.com/docs/5.1/routing#parameters-regular-expression-constraints or maybe https://laravel.com/docs/5.2/routing#route-model-binding
How could that be possible?