Developed with love by KnpLabs Hire us for your project!
126

TranslationEditorBundle

by servergrove

Symfony2 bundle that provides a web based UI editor for translation files

TranslationEditorBundle

The TranslationEditorBundle is a Symfony2 bundle that provides web base UI to manage Symfony2 translations.

The following command line tools are provided:

  • Import translation files

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

Import translation files into MongoDB. If no files is specified, the command will search for files in translations directories in src/

  • Export to translation files

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

Export translations to translation files from MongoDB. If no files is specified, the command will search for files in translations directories in src/

Screenshot

Installation:

Download or clone the bundle. If you use deps file add it like this:

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

Then run ./bin/vendors install

Add ServerGrove namespace to app/autoload.php:

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

Enable it in your app/AppKernel.php (we recommend that you do it only for the dev environments)

public function registerBundles()
{
    ...

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

    ...
}

Configuration:

We recommend that you only enable this bundle for the development environments, so only add the configuration in config_dev.yml

The collection parameter allows you to define the collection that will contain the translations for the project, so you can have multiple Symfony2 projects in the same mongodb server.

The mongodb parameters defines the mongodb server to connect to.

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

# enable bundle extension
server_grove_translation_editor: ~

Add the routing configuration to app/config/routing_dev.yml

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

Usage:

  1. Import translation files into mongodb

    ./app/console locale:editor:import

  2. Load editor in browser, edit your translations

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

  3. Export changes to translation files

    ./app/console locale:editor:export

WARNING

PLEASE Backup your translation files before using the editor. Use a source control system like git, even svn is ok. We are not responsible for lost information.

TODO

  • Support for nested yml format
  • Support for xliff files
  • Import strings from twig files
  • Ability to edit key
  • Add Google Translate API interface
  • Add Search capabilities

Pull requests are welcome! We open sourced this bundle hoping people find it useful. Please contribute back any enhancements.

Notice: This bundle has been developed with very short time availability so it does not contain tests, comments, etc, so don't look at it to see how things are done. Instead of complaining of the ugly code, please contribute pull requests with enhancements :)

More information:

Copyright (c) 2012 ServerGrove Networks, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Added pattern for file names
    By iambrosi, 7 years ago
  • Fixed bug that included empty/null lines in translation file
    By pgodel, 8 years ago
  • Using Yaml:Dumper to export translations to fix issues with special characters in keys
    By pgodel, 8 years ago
  • added tag
    By pgodel, 8 years ago
  • Added check for existence of key
    By pgodel, 8 years ago
  • * Added check for existing keys when adding a new key (update an existing entry instead)
    By pgodel, 8 years ago
  • Added scape for keys to prevent javascript errors
    By iambrosi, 8 years ago
  • Fixed bug when entries field is not an array
    By iambrosi, 8 years ago
  • Fixed issue #2: Merged message of different files
    By iambrosi, 8 years ago
  • added TODO list entry
    By pgodel, 8 years ago
  • added TODO list entry
    By pgodel, 8 years ago
  • more TODO
    By pgodel, 8 years ago
  • added screenshot
    By pgodel, 8 years ago
  • added missing routing configuration
    By pgodel, 8 years ago
  • initial commit
    By pgodel, 8 years ago