承接 kiberzauras/laravel.multilanguage 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kiberzauras/laravel.multilanguage

最新稳定版本:v2.0.5

Composer 安装命令:

composer require kiberzauras/laravel.multilanguage

包简介

Multilanguage support for Laravel 5.1+ routes

README 文档

README

This package is not maintained anymore, please use mcamara/laravel-localization instead!

Multilanguage for Laravel 5.1

Made for Laravel 5 Total Downloads Latest Stable Version Latest Unstable Version License

This package will help you to easy create multilanguage routes on top of your single language website. With this package you will be able to access your website with these routes example.com, example.com/en, example.com/en/page and etc. and there is no need to change your routes.php file!

Installation

At first you need to install our package:

composer require "kiberzauras/laravel.multilanguage"

Then you need to create new file under /config/multilanguage.json with this content:

{"default":"en","enabled":["en","ru","lt"]}

In /public/index.php file change these lines:

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

With these lines:

$response = $kernel->handle(
    $request = Kiberzauras\MultiLanguage\Request::capture()
);

Add new provider (/config/app.php providers[]):

Kiberzauras\MultiLanguage\MultiLanguageServiceProvider::class

Thats it, your application now can be accessed with url like these:

example.com
example.com/
example.com/en
example.com/en/
example.com/admin/page/etc
example.com/en/admin/page/etc

Now, try creating hyperlinks:

<?= URL::to('main/index'); ?> //or
<?= url('main/index'); ?> // will create route to /en/main/index (it will use default language as prefix)
<?= URL::to('main/index', ['language'=>'ru']) // will create create route/change default language to /ru/main/index
<?= route('profile'); ?>
<?= route('profile', ['language'=>'ru']); ?>

You can access current language like before:

App::getLocale();

Notes

For assets link, use asset('img/foo.jpg'); or secure_asset('foo/bar.zip', $title, $attributes = []); instead of url('img/foo.jpg'); https://laravel.com/docs/5.1/helpers#method-asset

License

The Laravel Multilanguage is open-sourced software licensed under the MIT license

统计信息

  • 总下载量: 711
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-22