servergrove/translation-editor-bundle

基于 Web 的界面来管理 Symfony2 翻译

dev-master 2012-08-15 13:29 UTC

This package is not auto-updated.

Last update: 2024-09-28 12:38:09 UTC


README

TranslationEditorBundle 是一个 Symfony2 扩展包,它提供了一个基于 Web 的用户界面来管理 Symfony2 翻译。

提供以下命令行工具

  • 导入翻译文件

    ./app/console locale:editor:import [--dry-run] [filename]

将翻译文件导入 MongoDB。如果没有指定文件,该命令将在 src/ 中的翻译目录中搜索文件。

  • 导出翻译文件

    ./app/console locale:editor:export [--dry-run] [filename]

从 MongoDB 将翻译导出到翻译文件。如果没有指定文件,该命令将在 src/ 中的翻译目录中搜索文件。

屏幕截图

安装

下载或克隆该扩展包。如果你使用 deps 文件,请按如下方式添加:

[TranslationEditorBundle]
	git=git://github.com/servergrove/TranslationEditorBundle.git
	target=/bundles/ServerGrove/Bundle/TranslationEditorBundle

然后运行 ./bin/vendors install

将 ServerGrove 命名空间添加到 app/autoload.php

$loader->registerNamespaces(array(
	...
	'ServerGrove' => __DIR__.'/../vendor/bundles',
	...
));

在 app/AppKernel.php 中启用它(我们建议只针对开发环境进行此操作)

public function registerBundles()
{
	...

    if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    	...
        $bundles[] = new ServerGrove\Bundle\TranslationEditorBundle\ServerGroveTranslationEditorBundle();
    }

	...
}

配置

我们建议你只为开发环境启用此扩展包,因此只需在 config_dev.yml 中添加配置

集合参数允许你定义将包含项目翻译的集合,这样你就可以在同一 MongoDB 服务器上拥有多个 Symfony2 项目。

mongodb 参数定义了要连接的 MongoDB 服务器。

parameters:
	translation_editor.collection: mytranslations
	translation_editor.mongodb: mongodb://:27017

# enable bundle extension
server_grove_translation_editor: ~

将路由配置添加到 app/config/routing_dev.yml

SGTranslationEditorBundle:
	resource: "@ServerGroveTranslationEditorBundle/Resources/config/routing.yml"
	prefix:   /

使用方法

  1. 将翻译文件导入 MongoDB

    ./app/console locale:editor:import

  2. 在浏览器中加载编辑器,编辑你的翻译

    http://your-project.url/translations/editor

  3. 将更改导出到翻译文件

    ./app/console locale:editor:export

警告

在使用编辑器之前备份你的翻译文件。使用源代码控制系统,如 git,即使 svn 也行。我们不负责丢失的信息。

待办事项

  • 支持嵌套 yml 格式
  • 支持 xliff 文件
  • 从 twig 文件导入字符串
  • 能够编辑键
  • 添加 Google 翻译 API 接口
  • 添加搜索功能

欢迎 pull requests!我们开源了这个扩展包,希望人们发现它有用。请贡献任何改进。

注意: 这个扩展包是在非常有限的时间内开发的,因此它不包含测试、注释等,所以不要看它来了解事情是如何完成的。而不是抱怨代码丑陋,请贡献 pull requests 来进行改进 :)

更多信息