Giter Site home page Giter Site logo

liiptranslationbundle's Introduction

UNMAINTAINED

This bundle is no longer maintained. Feel free to fork it if needed.

LiipTranslationBundle

Build Status

This Bundle provides various tools to ease translations management of a Sf2 app. Here is a small presentation of the bundle.

Introduction

This bundle adds a new layer on top of existing translation mechanisms. This allows your customers to edit and override any translations directly from the website.

Separation of concern

Using such a tool allows a clear separation between "key" and "value". Developers are responsible for defining new keys and removing old keys, while client/customer are responsible for translating the website.

Key values on steroid

The current basic key-value system could be better. We extend it and allow developers to complete keys with metadata (like it's possible with XLiFF).

Extend your keys with information like maxbytes, comment, description, urls, screenshot, etc... Anything that could help translators.

A "value" is the translation for a "key" in a given locale, it's also possible to complete it with metadata (comments, update date, validity, etc...)

Storage layer

The intermediate storage is currently available for:

  • Propel (database)
  • YAML (file or in Git)

but adding a new persistence implementation is very easy (you just have to implement a small interface)

Symfony compatibility

This bundle works on any Symfony versions 2.3+. Unit and functional tests have been written to ensure this compatibility.

Features

Translation interface in the backend

  • Edit through a contextual popup
  • Fast inline editing
  • Possibility to view various translated column at the same time (en, fr, pt, etc...)
  • Filter by locale, domain, date
  • Filter for untranslated key
  • Search by key name or translation value
  • Display help messages from the developers

Import/Export

Useful to provide files to an external agency, or to transfer translations from a staging environment to production

  • Export translation to a YAML file
  • Export based on the current list filter
  • Export/import multi domain/language with a zip file
  • Review change interface to handle collision at import time

New translation keys insertion

  • Developers can provide context information to a translation keys (maxsize, description, comment, url, etc..)
  • Symfony command for developers to insert new complex keys into Xliff

Security

  • Rights management (restricted to given locale or given domain)

Installation

  1. Via composer

     composer require liip/translation-bundle master-dev
    

Configuration

Include the bundle in your AppKernel.php:

public function registerBundles()
{
    $bundles = array(
        // ...
        new Liip\TranslationBundle\LiipTranslationBundle(),
        // ...
    );
    // ...
}

In your config.yml add the given Bundle specific configuration, for example:

liip_translation:
    locale_list: [en_JP, en_US, en, fr_CH, fr]
    security:
        by_domain: false
        by_locale: true
    persistence:
        class: Liip\TranslationBundle\Persistence\YamlFilePersistence
        options:
            folder: "%kernel.root_dir%/data/translations"
    interface:
        default_filters:
          domain: ['messages']
          languages: ['en', 'fr']

Also load the routes:

_liip_translation:
    resource: "@LiipTranslationBundle/Resources/config/routing.yml"
    prefix: /translation

Alternatively you can load the translation and import interface routes separately:

_liip_translation_interface:
    resource: "@LiipTranslationBundle/Resources/config/routing_translation_interface.yml"

_liip_translation_import_interface:
    resource: "@LiipTranslationBundle/Resources/config/routing_import_interface.yml"

Security

Access to translation management can be restricted by domains or by locales. By default, those restrictions are disabled, you can turn them on in the config, with:

liip_translation:
    ...
    security:
        by_domain: false
        by_locale: true

You can activate one or both restrictions together. Once this have been activated, you have to attribute associated roles to your users. The existing roles are:

ROLE_TRANSLATOR_ADMIN
    ROLE_TRANSLATOR_ALL_DOMAINS
        ROLE_TRANSLATOR_DOMAIN_XXX
    ROLE_TRANSLATOR_ALL_LOCALES
        ROLE_TRANSLATOR_LOCALE_XXX

!! Warning, if you use security by domain, you have to explicitly list the domains. Example:

    security:
        by_domain: true
        domain_list: [messages, validators, forms]

Contributing

Pull requests are welcome. Please see our CONTRIBUTING guide.

This bundle is fully tested with PHPUnit, the tests suite can be run using the following commands :

      git clone [email protected]:liip/LiipTranslationBundle.git && cd LiipTranslationBundle
      composer install --dev
      phpunit

Thanks to everyone who has contributed already.

liiptranslationbundle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liiptranslationbundle's Issues

Naming conventions

The commands in this bundle are called translation:<thing> - the naming convention would be liip:translation:<thing>. should we change this prior to the 1.0 release?

Support for doctrine storage

Hello,

Given that Doctrine is the primary lib used in SF2, is there any plan to implement support for it soon?

Translation extractor?

As of this moment I'm using JMS Translation bundle which is quite terrific but has not been actively maintained for a while. Anyhow, it as a very good support for message extractor which makes it super fast and easy to populate the trans list by scanning existing code.

I wonder if there is any plan for it. In any case I could use both bundles at the same time but I would prefer to use only one if possible. :)

fix HHVM support

see https://travis-ci.org/liip/LiipTranslationBundle/jobs/45996579

63.46s$ phpunit --coverage-text && phpunit Tests/Controller/SecurityTest.php
PHPUnit 4.4.0 by Sebastian Bergmann.
Configuration read from /home/travis/build/liip/LiipTranslationBundle/phpunit.xml.dist
....F............................
Time: 1.03 minutes, Memory: 64.63Mb
There was 1 failure:
1) Liip\TranslationBundle\Tests\Controller\ImportControllerTest::testProcessing
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'new_value2'
+'value2'

PCRE.backtrack_limit reached when using YamlFilePersistence

...
src/Acme/MyBundle/Resources/translations/messages.fr.yml  >> OK

  [Symfony\Component\Yaml\Exception\ParseException]                                                                                                                            
  pcre.backtrack_limit reached at line 8619 (near "- "<p>\n    Welcome to the ...... my long translation")

Exception trace:
 () at vendor/symfony/symfony/src/Symfony/Component/Yaml/Parser.php:245
 Symfony\Component\Yaml\Parser->parse() at vendor/symfony/symfony/src/Symfony/Component/Yaml/Parser.php:185
 Symfony\Component\Yaml\Parser->parse() at vendor/symfony/symfony/src/Symfony/Component/Yaml/Parser.php:185
 Symfony\Component\Yaml\Parser->parse() at vendor/symfony/symfony/src/Symfony/Component/Yaml/Parser.php:185
 Symfony\Component\Yaml\Parser->parse() at vendor/symfony/symfony/src/Symfony/Component/Yaml/Yaml.php:67
 Symfony\Component\Yaml\Yaml::parse() at src/Liip/TranslationBundle/Persistence/YamlFilePersistence.php:163
 Liip\TranslationBundle\Persistence\YamlFilePersistence->loadFile() at src/Liip/TranslationBundle/Persistence/YamlFilePersistence.php:157
 Liip\TranslationBundle\Persistence\YamlFilePersistence->loadFiles() at src/Liip/TranslationBundle/Persistence/YamlFilePersistence.php:50
 Liip\TranslationBundle\Persistence\YamlFilePersistence->getUnits() at src/Liip/TranslationBundle/Repository/UnitRepository.php:73
 Liip\TranslationBundle\Repository\UnitRepository->loadAll() at src/Liip/TranslationBundle/Repository/UnitRepository.php:98
 Liip\TranslationBundle\Repository\UnitRepository->findAll() at src/Liip/TranslationBundle/Repository/UnitRepository.php:104
 Liip\TranslationBundle\Repository\UnitRepository->getAll() at src/Liip/TranslationBundle/Repository/UnitRepository.php:110
 Liip\TranslationBundle\Repository\UnitRepository->getAllByDomainAndKey() at src/Liip/TranslationBundle/Import/SymfonyImporter.php:110
 Liip\TranslationBundle\Import\SymfonyImporter->processImportOfStandardResources() at src/Liip/TranslationBundle/Command/ImportCommand.php:71
 Liip\TranslationBundle\Command\ImportCommand->execute() at vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:244
 Symfony\Component\Console\Command\Command->run() at vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:904
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
 Symfony\Component\Console\Application->run() at app/console:36

Once this has been done, the interface throws this error :

FatalErrorException: Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 25568356 bytes) in vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php line 108
in vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php line 108
at ErrorHandler??handleFatal() in vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php line 0
at ??mb_strripos() in vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php line 108
at WebDebugToolbarListener??injectToolbar() in vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php line 89
at WebDebugToolbarListener??onKernelResponse() in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 0
at ??call_user_func() in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 450
at ??Symfony\Component\HttpKernel\Debug\{closure}() in app/cache/dev/classes.php line 0
at ??call_user_func() in app/cache/dev/classes.php line 1759
at EventDispatcher??doDispatch() in app/cache/dev/classes.php line 1692
at EventDispatcher??dispatch() in app/cache/dev/classes.php line 1856
at ContainerAwareEventDispatcher??dispatch() in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 139
at TraceableEventDispatcher??dispatch() in app/bootstrap.php.cache line 2864
at HttpKernel??filterResponse() in app/bootstrap.php.cache line 2888
at HttpKernel??handleException() in app/bootstrap.php.cache line 2823
at HttpKernel??handle() in app/bootstrap.php.cache line 2947
at ContainerAwareHttpKernel??handle() in app/bootstrap.php.cache line 2249
at Kernel??handle() in app/AppKernel.php line 89
at AppKernel??handle() in web/app_dev.php line 41
at ??{main}() in web/app_dev.php line 0

Broken layout on new installation

Hi, thanks for this useful bundle.

I've just installed it and this is what is see for /translation/list:

screenshot from 2015-07-25 03-06-24

I've run assets:install but it's still shown like that, look broken to me. Inline editing is not working either, but I don't see any Javascript error.

Thanks for any insight.

Integration with CreateBundle to edit translation in-place in the frontend

It would be awesome to allow inline editing of translation strings in the frontend with the CreateBundle. The user could edit the text right at the place where it is displayed.

We would need to come up with something clever how to display translations for this use case, as the HTML needs additional markup around each such string...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.