leyer / translation-addition
此扩展包允许您直接从应用程序用户界面使用JavaScript编辑翻译。
1.0.10
2015-09-21 17:57 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- jms/translation-bundle: >=1.1
This package is not auto-updated.
Last update: 2024-09-28 16:20:36 UTC
README
此扩展包允许您直接从应用程序用户界面使用JavaScript编辑翻译。
安装
使用composer安装扩展包
composer require "leyer/translation-addition"
您需要在app/AppKernel.php中注册此扩展包
public function registerBundles() { if (in_array($this->getEnvironment(), ['dev', 'test'])) { $bundles[] = new Leyer\TranslationAdditionBundle\LeyerTranslationAdditionBundle(); } }
如果您使用AsseticBundle,应发布此扩展包的资产
assetic: bundles: - LeyerTranslationAdditionBundle
php app/console assets:install --symlink web
这里有一个symfony扩展包这里。
用法
内联编辑翻译
内联编辑需要翻译更新器。
如果您使用了JMSTranslationBundle,适配器更新器已可用。别忘了添加至少一个配置
leyer_translation_addition: inline_translation: ~ jms_translation: configs: app: dir: [%kernel.root_dir%] output_dir: %kernel.root_dir%/Resources/translations
如果您想使用自己的更新器,必须实现TranslationUpdaterInterface并在配置中启用您的更新器服务
leyer_translation_addition: inline_translation: updater: my_adapter_definition
在app/config/routing_dev.yml中注册路由
_leyer_translation_addition: resource: "@LeyerTranslationAdditionBundle/Resources/config/routing.yml" prefix: /_trans
现在您必须包含js和css文件
{% if app.environment == 'dev' %}
<script src="{{ asset('bundles/leyertranslationaddition/js/translator.js') }}" type="text/javascript"></script>
{% endif %}
{% if app.environment == 'dev' %}
<link rel="stylesheet" href="{{ asset('bundles/leyertranslationaddition/css/translator.css') }}"/>
{% endif %}
待办事项
工具提示css。