AsgardCms / Platform

A modular multilingual CMS built with Laravel 5.
https://asgardcms.com/
MIT License
779 stars 240 forks source link

Display routing for all active language versions #701

Open LukaszNiziolDWG opened 5 years ago

LukaszNiziolDWG commented 5 years ago

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 commented 5 years ago

Hi,

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

arturmamedov commented 5 years ago

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
],
....