statikbe/laravel-chained-translator
Composer 安装命令:
composer require statikbe/laravel-chained-translator
包简介
The Laravel Chained Translator can combine several translators that can override each others translations.
README 文档
README
Laravel Chained Translator
The chained translator can combine several translators that can override each others translations. Typically, at some point during the development phase, a content manager wants to translate or finetune the translation strings added by developers. This often results in merge and versioning issues, when developers and content managers are working on the translation files at the same time.
The Chained Translator package allows translations created by developers to exist separately from translations edited by
the content manager in separate lang directories. The library merges the translations of both language directories,
where the translations of the content manager (the custom translations) override those of the developer (the default
translations).
For instance, the default translations created by developers are written in the default Laravel lang directory in
resources/lang, and the translations by the content manager are added to resources/lang-custom. When a translation
key exists in the resources/lang-custom directory, this is preferred, otherwise we fallback to the default
translations.
We offer two package that provide a UI to let content managers edit translations.
- Laravel Nova Chained Translation Manager for Laravel Nova
- Laravel Filament Chained Translation Manager for Laravel Filament
Installation
Via composer:
composer require statikbe/laravel-chained-translator
Commands
Merge the custom translations back into the default translation files
If you want to combine the translation files made in the current environment by the content manager with the default translation files, you can use the following command. You need to pass the locale as a parameter, since this library is agnostic of the locales supported by your Laravel application. Laravel sadly does not have a default supported locales list. So if you want to merge all files for all supported locales, run this command for each locale.
For example, for French:
php artisan chainedtranslator:merge fr
This command can be useful to merge the translation work of a translator back into the default translation files.
Configuration
You can publish the configuration by running this command:
php artisan vendor:publish --provider="Statikbe\LaravelChainedTranslator\TranslationServiceProvider" --tag=config
The following configuration fields are available:
1. Custom lang directory
By default, the custom translations are saved in resources/lang-custom. This can be configured using custom_lang_directory_name.
2. .gitignore in custom lang directory
If add_gitignore_to_custom_lang_directory is set to true, a .gitignore file is added to the custom
language directory.
3. Group keys in nested arrays
If group_keys_in_array is set to true, dotted translation keys will be mapped into arrays.
Set to true: saved as nested arrays, f.e.
'key' => [ 'detail' => 'translation', ]
Set to false: saved as dotted keys, f.e.
'key.detail' => 'translation',
4. Custom json group name
You can edit the group name of all json translations with the json_group.
Credits
We used Joe Dixon's translation libraries as a source of technical expertise and inspiration:
Thanks a lot for the great work!
License
The MIT License (MIT). Please see license file for more information.
statikbe/laravel-chained-translator 适用场景与选型建议
statikbe/laravel-chained-translator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 162.64k 次下载、GitHub Stars 达 37, 最近一次更新时间为 2020 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「translations」 「customer」 「laravel」 「custom」 「Chain」 「content manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 statikbe/laravel-chained-translator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 statikbe/laravel-chained-translator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 statikbe/laravel-chained-translator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Customer handling for PHP applications.
Customers management for Symfony projects.
Deepl Automated translations for Laravel lang files
Personalização dos formulários de clientes
Adds support for dynamic translations from Google Spreadsheets.
A Laravel package for multilingual models
统计信息
- 总下载量: 162.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 37
- 点击次数: 43
- 依赖项目数: 6
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-07
