creative/symfony-db-i18n-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

creative/symfony-db-i18n-bundle

最新稳定版本:v0.3.1

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.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固