M
M
Mokhirjon Naimov2015-06-21 11:06:49
Laravel
Mokhirjon Naimov, 2015-06-21 11:06:49

How to correctly use prefixes for localization in Laravel 4.2?

app/routes.php

Route::group(['prefix' => '{lang}', 'before' => 'localization'], function()
{
    Route::get('news', [
        'as'   => 'news',
        'uses' => '[email protected]',
    ]);

    Route::get('news/{id}', [
        'as'   => 'show_news',
        'uses' => '[email protected]',
    ]);
});

filters.php
Route::filter('localization', function()
{
    App::setLocale(Route::input('lang'));
});

{{ route('show_news', $item->id) }} returns site.com/1/news , but it should be http://site.com/{lang}/news/1
What's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mokhirjon Naimov, 2015-06-22
@zvermafia

I figured it out myself. It turns out you need to explicitly pass the prefix
Thought Laravel does it automatically.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question