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

i18n for slugs. Used config file to avoid performance impact #29

Closed
wants to merge 1 commit into from
Closed

i18n for slugs. Used config file to avoid performance impact #29

wants to merge 1 commit into from

Conversation

kiroushi
Copy link

@kiroushi kiroushi commented Dec 1, 2015

No description provided.

$locale = LaravelLocalization::setLocale() ?: App::getLocale();
$router->get('posts', ['as' => $locale . '.blog', 'uses' => 'PublicController@index']);
$router->get('posts/{slug}', ['as' => $locale . '.blog.slug', 'uses' => 'PublicController@show']);
$router->get(trans('blog::settings.posts-slug'), ['as' => $locale . '.blog', 'uses' => 'PublicController@index']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it, can we get rid of the $locale in the route names? It doesn't appear to do anything at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but I think it would not be the same for the route name en.blog as it would be for fr.blog.

A language switcher may need this information to switch between languages without losing the current scope.

@joshbrw
Copy link
Member

joshbrw commented Dec 1, 2015

Could this be a config item instead, similar to the backend URL?

@nWidart
Copy link
Member

nWidart commented Dec 1, 2015

Did you test that changing from one locale to another redirects to the correct URI ?

@kiroushi
Copy link
Author

kiroushi commented Dec 1, 2015

I did. Although I think there may be problems with non-existent languages configs since there is no fallback to a custom string if the translation does not exist. Something like:

trans('blog::settings.blog-slug', 'blog')

@kiroushi kiroushi closed this Dec 1, 2015
@kiroushi kiroushi deleted the i18n-for-slugs branch December 1, 2015 23:50
@kiroushi
Copy link
Author

kiroushi commented Dec 1, 2015

I'm closing this since I think every module in the future would need localised slugs. And that should be in a separate slugs.php file, not settings.php. Cleaner and clearer.

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

4 participants