Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Laravel çoklu dil rotaları | Laravel multi-language routes

License

Notifications You must be signed in to change notification settings

ahmetbarut/laravel-mutli-lang-route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Multi Language Routes

It's back with a simpler use than before Multilanguage route package similar to Symfony routes

Setup

    composer require ahmetbarut/laravel-multi-route

Features

  • Annotation Available
  • Multi-language
  • Middleware
  • Group
  • Prefix
  • Name

Usage

Simple Usage

If you want, you can specify the language to be used in the array and the index in return. This usage can inflate the route file

use AhmetBarut\Multilang\Route;
use App\Http\Controllers\SomeController;


Route::get([
    'en' => '/',
    'tr' => '/tr',
    'es' => '/es'
], function () {
    return 'index';
});

// OR

Route::get([
    'en' => '/',
    'tr' => '/tr',
    'es' => '/es'
], [SomeController::class, 'index']);

Usage With Annotations

Using it with annotations makes it look simpler and nicer, and it may be clearer to read which method supports which locales from the annotation.

It must be used with the @Route directive, otherwise it will not discover routes

example

use AhmetBarut\Multilang\Route;
use App\Http\Controllers\SomeController;

/**
 * @Route(en, /en)
 */
Route::get([SomeController::class ,'index']);


// SomeController.php
class SomeController extends Controller
{
    /**
     * @Route(en, /en)
     */
    public function index()
    {
        return 'index';
    }
}

Usage With Array Annotations

use AhmetBarut\Multilang\Route;
use App\Http\Controllers\SomeController;


Route::get([SomeController::class ,'index']);


// SomeController.php
class SomeController extends Controller
{
    /**
     * @Route([en =>, tr => /tr, es => /es])
     */
    public function index()
    {
        return 'index';
    }
}

You must use the group method to use features such as prefix, global middleware.

Usage With Name and Mmiddleware

use AhmetBarut\Multilang\Route;
use App\Http\Controllers\SomeController;


Route::group(['middleware' => 'web', 'prefix' => 'hello'], function () {
    Route::get([SomeController::class, 'index'])->name('home');
    Route::get([SomeController::class, 'create'])->name('create');
});


// SomeController.php
class SomeController extends Controller
{
    /**
     * @Route([en => /, tr => /tr, de => /de])
     */
    public function index()
    {
        return 'index';
    }
}

About

Laravel çoklu dil rotaları | Laravel multi-language routes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages