kiberzauras/laravel.multilanguage
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
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
kiberzauras/laravel.multilanguage 适用场景与选型建议
kiberzauras/laravel.multilanguage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 711 次下载、GitHub Stars 达 11, 最近一次更新时间为 2015 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「multilanguage」 「laravel」 「kiberzauras」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kiberzauras/laravel.multilanguage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kiberzauras/laravel.multilanguage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kiberzauras/laravel.multilanguage 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Puts the Symfony Translation Component on steroids
Puts the Symfony Translation Component on steroids
Management package for i18n static texts for TBP
Alfabank REST API integration
Translatable Eloquent's for Laravel 5
统计信息
- 总下载量: 711
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-22