richan-fongdasen/laravel-i18n
最新稳定版本:3.4.0
Composer 安装命令:
composer require richan-fongdasen/laravel-i18n
包简介
Simple route and eloquent localization / translation in Laravel
关键字:
README 文档
README
Laravel I18n
Simple Route localization and Eloquent translation in Laravel
Synopsis
This package provides easy ways to setup database translation and route localization.
Table of contents
Setup
Install the package via Composer :
$ composer require richan-fongdasen/laravel-i18n
Publish package assets
Publish the package asset files using this php artisan command
$ php artisan vendor:publish --provider="RichanFongdasen\I18n\ServiceProvider"
The command above would create three new files in your application, such as:
- New configuration file
/config/i18n.php - New database migration
/database/migrations/0000_00_00_000000_create_languages_table.php - New languages json file
/storage/i18n/languages.json
Configuration
return [ /* |-------------------------------------------------------------------------- | Language repository driver |-------------------------------------------------------------------------- | | Define your language repository driver here. The available options are: | database and json. | */ 'driver' => 'json', /* |-------------------------------------------------------------------------- | Language repository datasource |-------------------------------------------------------------------------- | | Define your language repository datasource here. | - Define your database table name, when you're using database driver. | - Define your json file path, when you're using json driver. | */ 'language_datasource' => storage_path('i18n/languages.json'), // 'language_datasource' => 'languages', /* |-------------------------------------------------------------------------- | Cache duration |-------------------------------------------------------------------------- | | Define how long we should cache the language dataset in seconds. | */ 'cache_duration' => 60 * 60 * 24, /* |-------------------------------------------------------------------------- | Language key |-------------------------------------------------------------------------- | | Define which language key in datasource that we should use. | Available options are: | - language, ie: en, es, de, etc. | - ietfCode, ie: en-US, en-UK, de-DE, etc. | */ 'language_key' => 'language', /* |-------------------------------------------------------------------------- | API query key |-------------------------------------------------------------------------- | | Define the query parameter name which will be used as language selector | in every API request. | e.g: http://localhost:8000/api/articles?lang=en | */ 'api_query_key' => 'lang', /* |-------------------------------------------------------------------------- | Language negotiator class |-------------------------------------------------------------------------- | | Define your language negotiator class here. | The class should implement LanguageNegotiator contract / interface. | */ 'negotiator' => \RichanFongdasen\I18n\Negotiators\BrowserNegotiator::class, /* |-------------------------------------------------------------------------- | Locale URL segment number |-------------------------------------------------------------------------- | | Define which url segment number that will be used to put the current | locale information. URL segment is started with '1'. | e.g: http://my-application.app/en/home | */ 'locale_url_segment' => 1, /* |-------------------------------------------------------------------------- | Translation table suffix |-------------------------------------------------------------------------- | | Define your preferred suffix to be appended to your database's | translation table name. | */ 'translation_table_suffix' => 'translations', /* |-------------------------------------------------------------------------- | Enable Store to the cache |-------------------------------------------------------------------------- | | Toggle store locale to the cache | */ 'enable_cache' => env('I18N_ENABLE_CACHE', true), ];
Documentation
Please check the documentation here https://laravel-i18n.richan.id/
Credits
- mcamara/laravel-localization - Route localization concepts in this repository was inspired by this package.
- Wico Chandra - Database translation concepts in this repository was inspired by his
Model Translationconcept. - dimsav/laravel-translatable - Some of database translation concepts in this repository was inspired by this package.
License
The MIT License (MIT). Please see License File for more information.
richan-fongdasen/laravel-i18n 适用场景与选型建议
richan-fongdasen/laravel-i18n 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 92.77k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「i18n」 「translation」 「routes」 「intl」 「laravel」 「localization」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 richan-fongdasen/laravel-i18n 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 richan-fongdasen/laravel-i18n 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 richan-fongdasen/laravel-i18n 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.
Easy to use i18n translation PHP class for multi-language websites
Block routes by IP
A custom URL rule class for Yii 2 which allows to create translated URL rules
Provides caching methods which can be easily used for caching routes.
A Laravel Eloquent model trait for translatable resource
统计信息
- 总下载量: 92.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04