fei/translate-package
Composer 安装命令:
composer require fei/translate-package
包简介
Translate client package integration for Objective PHP applications
README 文档
README
This package provide Translate Client integration for Objective PHP applications.
Installation
Translate Package needs PHP 7.0 or up to run correctly.
You will have to integrate it to your Objective PHP project with composer require fei/translate-package.
Integration
As shown below, the Translate Package must be plugged in the application initialization method.
The Translate Package create a Translate Client service that will be consumed by the application's middlewares.
<?php use ObjectivePHP\Application\AbstractApplication; use Fei\Service\Translate\Package\TranslatePackage; class Application extends AbstractApplication { public function init() { // Define some application steps $this->addSteps('bootstrap', 'init', 'auth', 'route', 'rendering'); // Initializations... // Plugging the Translate Package in the bootstrap step $this->getStep('bootstrap') ->plug(TranslatePackage::class); // Another initializations... } }
Application configuration
Create a file in your configuration directory and put your Translate configuration as below:
<?php use Fei\Service\Translate\Package\Config\TranslateParam; use Fei\ApiClient\Transport\BasicTransport; return [ new TranslateParam('base_url', 'http://translate.api/'), // Translate API URL and port new TranslateParam('transport', new BasicTransport()), // Transport type new TranslateParam('translate_directory', '/app/translate/'), // Directory to store the translations new TranslateParam('translate_config', [ 'lock_file' => '/app/translate/.translations.lock', 'data_path' => '/app/translate/data', 'translations_path' => '/app/translate/translations', 'localTranslationsFile' => dirname(__DIR__) . '/localTranslations.php', 'skipSubscription' => false, 'servers' => [ 'http://translate.api/' => [ 'namespaces' => ['/mynamespace'], 'host' => 'other-host' ] ], 'url' => 'http://translate.domain.dev/handleRequest.php' ]),// Translate client config (Cf. Translate Client documentation) new TranslateParam('translate_namespace', '/mynamespace'), // Namespace defined in translate_config where to search the translations new TranslateParam('translate_lang', 'en_GB') // Language defined in which we want the translations ];
In the previous example you need to set this configuration:
base_url: represent the URL where the API can be contacted in order to send the translationstransport: represent the translations transport typetranslate_directory: represent the path to the directory to store the translationstranslate_config: represent the translate client configuration (Cf.translate-clientdocumentation)translate_namespace: represent the default namespace where to search the translationstranslate_lang: represent the default language in which we want the translations
Note that if you want your application to use local translations and not subscribe to a Translate server you can configure your application like this:
<?php use Fei\Service\Translate\Package\Config\TranslateParam; return [ new TranslateParam('translate_config', [ 'localTranslationsFile' => dirname(__DIR__) . '/localTranslations.php', 'skipSubscription' => true, ]), ];
Please check out translate-client documentation for more information about how to use this client.
fei/translate-package 适用场景与选型建议
fei/translate-package 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.37k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fei/translate-package 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fei/translate-package 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2019-01-04