定制 creative/symfony-db-i18n-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

creative/symfony-db-i18n-bundle

Composer 安装命令:

composer require creative/symfony-db-i18n-bundle

包简介

Allow store i18n-messages in database

README 文档

README

Sometimes You have to give the visual interface of i18n message CRUD for a customer. To do this, You need to have storage, which is not under version control and allowed from a form.

I18n messages stored in database

With this bundle i18n messages stored in a database instead of files, then, you can implement web-interface to manage it.

Installation

composer require creative/symfony-db-i18n-bundle

Bundle has not (yet) a flex auto-configurator. Add

Creative\DbI18nBundle\DbI18nBundle::class => ['all' => true],

to you config/bundles.php file, and (optional) place the db_i18n.yaml with configuration (see below) file to your config directory.

Some rules:

  • you application service container must have aa array locales parameter with possible application locales. For example:
    # config/services.yaml
    parameters:
      locales: [ 'ru', 'en', 'de' ]
  • implementation of Symfony\Contracts\Translation\TranslatorInterface must have a getCatalogue method (usually, it have) for import messages from translation files to database.
  • You must define the default messages domain as db_messages in you views to use messages from database. For example:
    # templates/main.html.twig
    {% trans_default_domain 'db_messages' %}
  • update you database schema after install this bundle — use bin/console doctrine:schema:update command or make migration for this.

So, now you can load messages from old translation files to the database. Command

bin/console creative:db-i18n:migrate translations/messages.en.yaml

will import all messages from [project root]/translations/messages.en.yaml. You can set absolute path instead, nevermind, but file name must be compatible with Symfony localization files agreement — <domain>.<locale>.<format>.

After (or instead of) that, make your forms/interfaces and add, change and so on with your messages.

Defaults

Default config is

# src/Resources/config/db_i18n.yaml
db_i18n:
  entity: Creative\DbI18nBundle\Entity\Translation
  domain: db_messages

Copy this wherever you want and modify.

As you can see, the default messages domain is db_messages. If you want to override this and store default Symfony domain messages in a database, don't forget to remove (or rename) you translations/messages.<locale>.[yaml|csv|xlf] file.

creative/symfony-db-i18n-bundle 适用场景与选型建议

creative/symfony-db-i18n-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.81k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2019 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「i18n」 「translations」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 creative/symfony-db-i18n-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 creative/symfony-db-i18n-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 creative/symfony-db-i18n-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 17
  • Watchers: 0
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-22