kikwik/db-trans-bundle
Composer 安装命令:
composer require kikwik/db-trans-bundle
包简介
Database translation loader with on-page translations edit for symfony 5
README 文档
README
Translation loader from database for symfony 5.
This bundle is inspired by the work of andrew72ru in creative/symfony-db-i18n-bundle
Installation
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require kikwik/db-trans-bundle
Update the database to create the translations tables:
$ php bin/console make:migration $ php bin/console doctrine:migrations:migrate
Configuration
Create the config/packages/kikwik_db_trans.yaml config file and define the locales (and clear the cache)
kikwik_db_trans: locales: [ it, en ]
Import routes bundle in config/routes/kikwik_db_trans.yaml:
kikwik_db_trans_bundle: resource: '@KikwikDbTransBundle/Resources/config/routes.xml' prefix: '/'
Run the kikwik:db-trans:import-messages command to init the database translation and import messages from an existing catalogue with the domain as parameter:
$ ./bin/console kikwik:db-trans:import-messages myDomain
In the translation directory of the project will be created a file named db_myDomain.locale.db for each enabled locale
Usage
You can use these twig translation functions:
db_transwill display database translations.editable_db_transwill display database translations for normal users, but:- if user has the
ROLE_TRANSLATORpermission then the translation can be modified directly on the page (an icon will appear when the mouse is over the translation) - be ware that this function will surround the translated string with a span element.
- if user has the
For both functions parameters are same as trans twig filter:
- message
- arguments (optional)
- domain (optional)
- locale (optional)
Both functions will try to translate appending the domainPrefix so the {{ db_trans('some.mesage',{},'myDomain') }} function will search for some.mesage key in the db_myDomain domain.
If this translation is not found it will fallback to the original domain translation (equivalent to {{ 'some.mesage'| trans({},'myDomain') }} )
kikwik/db-trans-bundle 适用场景与选型建议
kikwik/db-trans-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kikwik/db-trans-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kikwik/db-trans-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-19