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

Display routing for all active language versions #701

Open
LukaszNiziolDWG opened this issue Apr 30, 2019 · 2 comments
Open

Display routing for all active language versions #701

LukaszNiziolDWG opened this issue Apr 30, 2019 · 2 comments

Comments

@LukaszNiziolDWG
Copy link

LukaszNiziolDWG commented Apr 30, 2019

I have a route:

$router->group(['prefix' => trans('core::routes.realization.index')], function (Router $router) {
    $locale = LaravelLocalization::setLocale() ?: App::getLocale();
    $router->get('/', [
        'as' => $locale . '.realization',
        'uses' => 'PublicController@index',
    ]);
    $router->get('{category_slug}', [
        'as' => $locale . '.realization.category.slug',
        'uses' => 'PublicController@showRealizationCategory',
    ]);
    $router->get('{category_slug}/{realization_slug}', [
        'as' => $locale . '.realization.slug',
        'uses' => 'PublicController@showRealization',
    ]);
});

I want to display links in every language:

            <ul>
                @foreach(LaravelLocalization::getSupportedLocales() as $localeCode => $properties)
                <li>
                    <a rel="alternate" hreflang="{{ $localeCode }}" href="{{LaravelLocalization::getLocalizedURL($localeCode) }}">
                        {{ $properties['native'] }}
                    </a>
                </li>
                @endforeach
            </ul>

Unfortunately, the translations are not substituted in place of the prefix.

Result:
/realizacje
/en/realizacje
/fr/realizacje

The expected result:
/realizacje
/en/realizations
/fr/realisations

@nWidart
Copy link
Member

nWidart commented Apr 30, 2019

Hi,

This seems to be an issue with laravel localization package, I would suggest to report it there.

@arturmamedov
Copy link
Contributor

Are you sure you add the localize midleware and set properly the prefix? I never do this but i think you miss this portion of code

https://github.com/mcamara/laravel-localization#translated-routes

Route::group(
[
	'prefix' => LaravelLocalization::setLocale(),
	'middleware' => [ 'localize' ] // Route translate middleware
],
....

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

No branches or pull requests

3 participants