brotzka/laravel-translation-manager
Composer 安装命令:
composer require brotzka/laravel-translation-manager
包简介
Lets you manage your Laravel-translation files via database.
README 文档
README
Laravel Translation Manager
This package provides an easy way to manage your translations in a database. It takes all files from your default locale folder (e.g. resources/lang/de) and creates translation-groups (e.g. auth.php becomes translation-group auth) which are stored in translation_groups-table. Then every entry from each file will be saved to the translations-table (yes, it takes care of multidimensional arrays of every depth).
After you have finished translating, the package writes all entries back to the resource-folder. All entries will be kept in database, so you can keep translating.
Updates are handled one-way. That means that changes which are made to a file will not replace the value in the database. The other way round, the complete content of a translation-file will be replaced by the values from the database.
Pros:
- Laravels default translation-loader will not be replaced, so everything keeps working
- Works with every Laravel version (5.*)
- To add a new language, simply add it to your
config/app.phpand re-runphp artisan translations:toDatabse, make your translations and runphp artisan translations:toFile - No more database exports! Develop locally without using the export function. Simply use your default language.
Installation
- require via composer
composer require brotzka/translation-manager - add list of available languages to your
config/app.php:
'available_locales' => ['de', 'en', 'sv'],
- run migration
php artisan migrate
Commands
translations:toDatabase
Call via:
php artisan translations:toDatabase
Collects all files and entries from within your resources/lang/ folder and generates translations-groups and translations and writes them to the database. Existing files will NOT be updated.
translations:toFile
Call via:
php artisan translations:toFile
Takes all entries from the database, generates missing language folders and translation-group files and puts the values to the files.
NOTE: If you want to call the commands via Artisan::call('translations.toDatabase'), you have to register both commands in app/Console/Kernel.php:
protected $commands = [
// .. other commands
\Brotzka\TranslationManager\Module\Console\Commands\TranslationToDatabase::class,
\Brotzka\TranslationManager\Module\Console\Commands\TranslationToFile::class,
];
Usage
In the back, this package creates two more models (TranslationGroup and Translation) tables (translation_groups and translations).
You can use them as you are used to use models in Laravel. The relevant namespace is: Brotzka\TranslationManager\Module.
You can query relationships like this:
$translation->getParent: returns the parent-instance if existing (NULL if not)$translation->children: returns all children-instances$translation->getGroup: returns the translation-group of the current translation$translationGroup->entries: returns all entries belonging to the current translation-group
Future-Plans
- handle JSON-files
- provide some GUI-elements (e.g. language-switcher, translation-manager)
brotzka/laravel-translation-manager 适用场景与选型建议
brotzka/laravel-translation-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 68 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 brotzka/laravel-translation-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brotzka/laravel-translation-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-07