manuelj555/manuel-translation-bundle

此包的最新版本(v2.0)没有可用的许可证信息。


README

此Bundle允许从数据库创建和编辑翻译标签。您可以简单地创建和修改标签翻译,而不必触碰xml、yml、php等文件。此外,您还可以轻松地从Profiler创建尚未翻译的标签。

安装

执行

composer require optimeconsulting/manuel-translation-bundle @dev

然后,在 config/bundles.php 中注册这些bundles。

return [
    ...
    ManuelAguirre\Bundle\TranslationBundle\ManuelTranslationBundle::class => ['all' => true],
    ...
];

配置ManuelTranslationBundle

此bundle允许我们从数据库编辑和管理翻译,可以从网页编辑,并且允许我们同步项目服务器和本地之间的翻译。

为了添加其配置,需要创建一个名为 config/packages/manuel_translation.yaml 的文件。

manuel_translation:
    locales: [en, es] # Se deben definir los locales que el translator usará.
    security_role: ROLE_SUPER_ADMIN # Valor por defecto si no se define la opción.

config/routes.yaml 中添加

manuel_translation:
    resource: "@ManuelTranslationBundle/src/Controller/"
    type:     annotation
    prefix:   /{_locale}/admin/trans
#    requirements:
#        _locale: "%locales_pattern%"

config/packages/security.yaml 中调整翻译管理员的 access_control

    access_control:
        - ...
        - { path: "^/[a-z]{2,4}/admin/trans", allow_if: 'is_granted("manage_translations")' }
        - ...

is_granted("manage_translations") 允许进入翻译管理员界面,当您有配置在 manuel_translation.security_role 中的角色,或者当项目在本地服务器上运行时,在这种情况下,您可以访问翻译管理员界面而无需认证。

最后,您需要创建数据库(如果尚未创建),并将适合此bundle的表添加到数据库中,因此需要执行以下控制台命令

php app/console doctrine:database:create
php app/console doctrine:schema:update --force

此外,需要执行以下命令

php app/console assets:install

这样,bundle就安装正确了。