dusanbre/laravel-tolgee
Composer 安装命令:
composer require dusanbre/laravel-tolgee
包简介
Help with Laravel integration of Tolgee service
README 文档
README
This package provides integration with Tolgee service with Laravel apps.
Installation
You can install the package via composer:
composer require dusanbre/laravel-tolgee
You can publish the config file with:
php artisan vendor:publish --tag="laravel-tolgee-config"
This is the contents of the published config file:
return [ /* * Specify the path to your language files * Default is 'lang' it can be set to 'resources/lang' */ 'lang_path' => env('TOLGEE_LANG_PATH', 'lang'), /* * Specify a language files subfolder, in order to filter specific language files.Please be aware that this applies to subfolders within your base local folders. * So if you have folder structure like `lang/en/messages/...`, you can set this env variable to `messages` and package will use only files from messages folder. */ 'lang_subfolder' => env('TOLGEE_LANG_SUBFOLDER'), /* * Host to you Tolgee service instance * Please note that if you are using Sail for local development, service need to be in the same docker network * and you will need to set host in the format of 'http://{docker_tolgee_service_name}:{docker_tolgee_service_port}' */ 'host' => env('TOLGEE_HOST', 'https://app.tolgee.io'), /** * Project ID of your Tolgee service. */ 'project_id' => env('TOLGEE_PROJECT_ID'), /** * Valid api key from Tolgee service for the given project. * Api key needs to have all permissions to manage project. */ 'api_key' => env('TOLGEE_API_KEY'), /** * Base locale of the project. * Please note that the locale you set here should match the base language in your project. */ 'locale' => env('TOLGEE_LOCALE', 'en'), /** * Override base locale translations files. */ 'override' => env('TOLGEE_OVERRIDE', false), /** * Accepted translation states. Check Tolgee documentation for available states. * Ex: REVIEWED,DISABLED,UNTRANSLATED,TRANSLATED */ 'accepted_states' => explode(",", env('TOLGEE_ACCEPTED_STATES', 'REVIEWED')), ];
Usage
Package provides several Artisan commands to work with you translations in Tolgee.
- Import keys from your local files into Tolgee service
php artisan tolgee:keys:sync --with-vendors
- Delete all keys from Tolgee service
php artisan tolgee:keys:flush
- Import translations from Tolgee service into your local files
php artisan tolgee:translations:sync
You will need to have Tolgee instance set up in your config file.
Configuration
If you want to use this locally in your project you can run it on the docker container:
- Add service in your docker-compose.yml
...
tolgee:
image: tolgee/tolgee
volumes:
- sail-tolgee:/data
- ./tolgee.config.yaml:/config.yaml
ports:
- '25432:25432'
- '9090:8080'
environment:
spring.config.additional-location: file:///config.yaml
networks:
- sail
...
volumes:
...
sail-tolgee:
driver: local
- Add config
tolgee.config.yamlin root of you project
tolgee:
authentication:
enabled: true
initial-password: admin
initial-username: admin
jwt-secret: <jwt-secret> // Random string
machine-translation:
google:
api-key: <google-translations-api-key> // If you want to use google translation
smtp:
auth: false
from: Tolgee <no-reply@nibblo.com>
host: mailpit
password: 'password'
port: 1025
ssl-enabled: false
username: user@company.com
You can see more about configuration and setup on Tolgee docs
- Restart docker containers
- Publish laravel translation files
php artisan lang:publish - Edit local translation files
- Use package commands to sync it with Tolgee
NOTE
You should be able to access Tolgee service on http://localhost:9090
When you setup is dockerized, you will need to set TOLGEE_HOST for docker internal network. In this case that would be
http://tolgee:8080
Limitations
All operations are constrained to one project.
This will be fixed/implemented in the future.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
dusanbre/laravel-tolgee 适用场景与选型建议
dusanbre/laravel-tolgee 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.99k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2024 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「tolgee」 「Dusan Antonijevic」 「laravel-tolgee」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dusanbre/laravel-tolgee 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dusanbre/laravel-tolgee 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dusanbre/laravel-tolgee 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony Tolgee Translation Provider Bridge
Integrate Tolgee with your Laravel project
Symfony Tolgee Translation Provider Bridge
Alfabank REST API integration
Symfony Tolgee Translation Provider Bridge
tolgee lang
统计信息
- 总下载量: 6.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-29