Git Product home page Git Product logo

argentumtranslationbundle's Introduction

ArgentumTranslationBundle

SensioLabsInsight Build Status Coverage Status Latest Stable Version License

ArgentumTranslationBundle provides a database storage for translations and GUI for editing them.

This bundle supports PHP 5.4+ and Symfony 2.3+.

The bundle combines the power of the following bundles:

Installation

Install the bundle with composer:

composer require argentum/translation-bundle:dev-master

Register the bundle in app/AppKernel::registerBundles():

$bundles = array(
    // ...
    new Argentum\TranslationBundle\ArgentumTranslationBundle(),
    // ...
);

Configuration

In the parameters.yml you should configure a list of locales:

parameters:
    locales:
        - ru
        - uk
        - en

Then in the config.yml you should add the following options:

a2lix_translation_form:
    locales: %locales%

argentum_translation:
    locales: %locales%

Make sure you have registered KnpLabs DoctrineBehaviors Listeners in your config.yml:

imports:
    - { resource: ../../vendor/knplabs/doctrine-behaviors/config/orm-services.yml }

and have registered A2lixTranslationFormBundle in app/AppKernel::registerBundles():

$bundles = array(
    // ...
    new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
    // ...
);

And finally, create translation tables in your database:

app/console doctrine:schema:update --force

or create a migration and execute it:

app/console doctrine:migrations:diff
app/console doctrine:migrations:migrate

Translation editor

Now you can use GUI for editing the translations.

The bundle will automatically add additional items in the menu of your Sonata Admin. If you have customized the menu, you should add Translation group in config.yml:

sonata_admin:
    dashboard:
        groups:
            // ...
            Translation: ~

The list of all domains is located at URL something like (depends on the base location of Sonata Admin in your project): /admin/argentum/translation/translationdomain/list.

Loading order

When merging all translations together translations from files in all bundles will be loaded, and then all translations from the database will be loaded. Thus, translations from the database can override any translation from the translation files in your project.

Proposed workflow

Firstly, when developing your project you should use admin panel to create all necessary domains and add all necessary translations to them.

Secondly, when your bundle is ready, you should export all translations for the bundle domain into the bundle translation files and commit them to VCS.

And finally, when your project is started, you or your client can edit any translation without need to edit project files.

Cache

All translations are cached in the cache files and will be loaded from the database only once after clearing the cache.

Export

This bundle allows you to export translations from the database for single domain or all domains in the specified directory for the specified locales using the specified format.

Export all translations to the directory:

app/console translation:export --dir=/path/to/translations

Export translations for domain "messages":

app/console translation:export --dir=/path/to/translations messages

Export translations for domain "messages" and locales "ru" and "uk" in xliff format:

app/console translation:export --dir=/path/to/translations --locales="ru,uk" --format=xlf messages

Import

This bundle allows you to import translations from files into the database.

Import all translations from the specified directory:

app/console translation:import --dir=/path/to/translations

Import translations from the directory only for the domain "messages":

app/console translation:import --dir=/path/to/translations messages

Import translations from the directory only for the domain "messages" and locales "ru" and "uk":

app/console translation:import --dir=/path/to/translations --locales="ru,uk" messages

Import translations from the specified bundles:

app/console translation:import --bundles="SonataAdminBundle, SonataUserBundle"

Import translations from the entire project including all bundles, Form and Validation components, and local application translations:

app/console translation:import

argentumtranslationbundle's People

Contributors

javer avatar

Stargazers

Max Kovpak avatar Tomáš Naibrt avatar Sébastien Vérité avatar Mate Skoblar avatar

Watchers

 avatar James Cloos avatar Frédéric HENNINOT avatar

argentumtranslationbundle's Issues

You have requested a non-existent service "doctrine"

SF 3.4
doctrine orm 2.5
doctirne bundle 1.6

When i install the bundle, got this error, if i desactive it, the error gone.

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
  You have requested a non-existent service "doctrine". Did you mean one of these: "argentum.translation.loader.database", "translation.loader.csv", "translation.loader.dat", "translation.loader.ini", "translation.loader.json", "translation.loader.mo", "translation.lo
  ader.php", "translation.loader.po", "translation.loader.qt", "translation.loader.res", "translation.loader.xliff", "translation.loader.yml"?

Can't delete cache or update composer

No identifier/primary key specified for Entity TranslationDomainTranslation and TranslationUnitTranslation

  [Doctrine\ORM\Mapping\MappingException]
  No identifier/primary key specified for Entity "Argentum\TranslationBundle\Entity\TranslationDomainTranslation". Every Entity must have an identifier/primary key.

[FAIL] Argentum\TranslationBundle\Entity\TranslationDomainTranslation
No identifier/primary key specified for Entity "Argentum\TranslationBundle\Entity\TranslationDomainTranslation". Every Entity must have an identifier/primary key.

[OK]   Argentum\TranslationBundle\Entity\TranslationDomain
[FAIL] Argentum\TranslationBundle\Entity\TranslationUnitTranslation
No identifier/primary key specified for Entity "Argentum\TranslationBundle\Entity\TranslationUnitTranslation". Every Entity must have an identifier/primary key.

SF 3.4
doctrine orm 2.5
doctirne bundle 1.6

[Semantical Error] line 0, col 119 near 't WITH t.locale': Error: Class Argentum\TranslationBundle\Entity\TranslationDomain has no association named translations

After installation, when i called admin/argentum/translation/translationdomain/list
or /admin/argentum/translation/translationunit/list returned some errors:

[Semantical Error] line 0, col 119 near 't WITH t.locale': Error: Class Argentum\TranslationBundle\Entity\TranslationDomain has no association named translations

[2/2] QueryException: [Semantical Error] line 0, col 119 near 't WITH t.locale': Error: Class Argentum\TranslationBundle\Entity\TranslationDomain has no association named translations +

[1/2] QueryException: SELECT count(DISTINCT o.id) as cnt FROM Argentum\TranslationBundle\Entity\TranslationDomain o LEFT JOIN o.translations t WITH t.locale = :locale

[Semantical Error] line 0, col 117 near 't WITH t.locale': Error: Class Argentum\TranslationBundle\Entity\TranslationUnit has no association named translations
500 Internal Server Error - QueryException
1 linked Exception: QueryException »

[2/2] QueryException: [Semantical Error] line 0, col 117 near 't WITH t.locale': Error: Class Argentum\TranslationBundle\Entity\TranslationUnit has no association named translations

[1/2] QueryException: SELECT count(DISTINCT o.id) as cnt FROM Argentum\TranslationBundle\Entity\TranslationUnit o LEFT JOIN o.translations t WITH t.locale = :locale +

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.