vagkaefer/laravel-simplified-translation-manager
Composer 安装命令:
composer require vagkaefer/laravel-simplified-translation-manager
包简介
A laravel package to manage Laravel translations
README 文档
README
Laravel offers a robust solution for managing multiple languages. However, as the project scales, incorporating numerous languages and developers, managing translations can become intricate, leading to occasional lapses in translations variables across files.
The solution to this issue lies within this package. It mandates that developers add new translation variables solely in English (en) language. Once this is done, the package takes over, processing all languages and making appropriate adjustments to all variables. This streamlines the translation process and ensures consistency across all language files.
In addition, there are also additional settings, such as adding Suffixes or Prefixes to variables without translation, to help identify them.
Working process
The package will do this:
- Create a backup of the current lang/ folder
- Get the languages of the system (folders of lang/)
- Sort keys alphabetically of the templates files inside en/ folder
- Merge all keys of English base with anothers languages
- If the file doesn't exist, the package will create automaticaly
- If the destiny file contains translated keys, they will not be changed
- The new keys will receive a prefix or/and suffix (see config)
- All keys will be sorted alphabetically
Version Control
The version of the package is related with the Laravel Version:
| Package Version | Laravel version |
|---|---|
| v10 | v10 |
How to Install
The installation is made via composer in your Laravel project:
php composer require vagkaefer/laravel-simplified-translation-manager --dev
How to Configure
You can define the options with the config file or via Environment variables:
The ENV variables are:
SIM_TRANS_MANAGER_PREFIX=
SIM_TRANS_MANAGER_SUFFIX=" - NEED TRANSLATION"
SIM_TRANS_MANAGER_ALPHABETIZE_ENGLISH=true
SIM_TRANS_MANAGER_ALPHABETIZE_OUTPUT=true
SIM_TRANS_MANAGER_BACKUP=true
To publish the config file using the command:
php artisan vendor:publish --provider=VagKaefer\\LaravelSimplifiedTranslationManager\\ManagerServiceProvider
The options are:
-
prefix: (string) When a new translation word is detected, the prefix string is added in the beginning of the translation value
-
suffix: (string) When a new translation word is detected, the suffix string is added to the end of the translation value
-
alphabetize_english: (boolean - default true) This option will sort alphabetically all the keys of the English files
-
alphabetize_output_files: (boolean - default true) This option will sort alphabetically all the keys of the merged files with the languages
-
backup_original_files: (boolean - default true) This option will generate a .zip backup before every run, the zip can be found in the folder /lang/backups/
How to use
Write all the variables in the English (lang/en) templates, always include new variables in English.
Now you just need to run the process command:
php artisan sim-trans-manager:process
You will see the Output:
php artisan sim-trans-manager:process
Creating backup...backup generated in ./lang/backups/1686168359-lang-backup.zip
Sorting alphabetically english files:
File lang/en/auth.php sorted alphabetically
File lang/en/global.php sorted alphabetically
File lang/en/pagination.php sorted alphabetically
File lang/en/passwords.php sorted alphabetically
File lang/en/validation.php sorted alphabetically
Mergin with language 'pt_BR'
File lang/en/auth.php merged with lang/pt_BR/auth.php
File lang/en/global.php merged with lang/pt_BR/global.php
File lang/en/pagination.php merged with lang/pt_BR/pagination.php
File lang/en/passwords.php merged with lang/pt_BR/passwords.php
File lang/en/validation.php merged with lang/pt_BR/validation.php
Mergin with language 'es'
File lang/en/auth.php merged with lang/es/auth.php
File lang/en/global.php merged with lang/es/global.php
File lang/en/pagination.php merged with lang/es/pagination.php
File lang/en/passwords.php merged with lang/es/passwords.php
File lang/en/validation.php merged with lang/es/validation.php
Do you like the package?
You can help me with a coffee ;D
License
As Laravel framework, this packages is open-sourced software licensed under the MIT license.
vagkaefer/laravel-simplified-translation-manager 适用场景与选型建议
vagkaefer/laravel-simplified-translation-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 118 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vagkaefer/laravel-simplified-translation-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vagkaefer/laravel-simplified-translation-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 118
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-07