kikwik/db-trans-bundle 问题修复 & 功能扩展

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

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

kikwik/db-trans-bundle

最新稳定版本:v1.0.7

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_trans will display database translations.
  • editable_db_trans will display database translations for normal users, but:
    • if user has the ROLE_TRANSLATOR permission 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.

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') }} )

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-19