2017 © Pedro Peláez
 

library translation_editor

image

netpeople/translation_editor

  • Wednesday, August 7, 2013
  • by manuelj555
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

TranslatorBundle

This bundle's purpose is to provide an interface for edition, addition and deletion of translations messages., (*1)

Currently supported formats:, (*2)

  • YAML
  • XLIFF
  • CSV

Install & setup the bundle

  1. Fetch the source code, (*3)

    Using Git to control your project from project root directory:, (*4)

    ``` bash, (*5)

    git submodule add git://github.com/docteurklein/TranslatorBundle.git vendor/bundles/Knp/Bundle/TranslatorBundle, (*6)


    By cloning repository: ``` bash mkdir -p vendor/bundles/Knp/Bundle cd !$ git clone git://github.com/docteurklein/TranslatoBundle.git

    By including into deps file:, (*7)

    ``` ./deps-file, (*8)

    [TranslatorBundle] git=git://github.com/docteurklein/TranslatorBundle.git target=/bundles/Knp/Bundle/TranslatorBundle, (*9)

    ```, (*10)

  2. Add the bundle to your AppKernel class, (*11)

    ``` php, (*12)

    // app/AppKernerl.php public function registerBundles() { $bundles = array( // ... new Knp\Bundle\TranslatorBundle\KnpTranslatorBundle, // ... ); // ... }, (*13)

    ```, (*14)

  3. Add the Knp namespace to your autoloader, (*15)


    // app/autoload.php $loader->registerNamespaces(array( 'Knp' => __DIR__.'/../vendor/bundles', // your other namespaces );
  4. Add routing, (*16)

    ``` yaml, (*17)

    // app/config/routing.yml, (*18)

    knplabs_translator_admin: resource: @KnpTranslatorBundle/Resources/config/routing/edition.yml prefix: /trans/admin, (*19)

    knplabs_translator: resource: @KnpTranslatorBundle/Resources/config/routing/routing.yml prefix: /trans, (*20)

    ```, (*21)

These route files provide the following routes:, (*22)

[router] Current routes
Name                     Method  Pattern
knplabs_translator_list  GET    /trans/admin/list
knplabs_translator_get   GET    /trans/{id}/{domain}/{locale}
knplabs_translator_put   PUT    /trans/

Minimal configuration

This bundle requires the activation of the core translator:, (*23)

``` yaml

// app/config/config.yml
framework:
    # ...
    translator:    { fallback: en }
    # ...

```

Additional configuration

This bundle relies on the Ext Core library. You can decide wheter or not it will be included automatically., (*24)

``` yaml

knplabs_translator:
    include_vendor_assets: false # defaults to true

```

Services

This bundle introduces those services:, (*25)

translator.dumper.csv                    container Knp\Bundle\TranslatorBundle\Dumper\CsvDumper
translator.dumper.xliff                  container Knp\Bundle\TranslatorBundle\Dumper\XliffDumper
translator.dumper.yaml                   container Knp\Bundle\TranslatorBundle\Dumper\YamlDumper
translator.writer                        container Knp\Bundle\TranslatorBundle\Translation\Translator

controllers are services too:

knplabs_translator.controller.edition    request   Knp\Bundle\TranslatorBundle\Controller\EditionController
knplabs_translator.controller.translator request   Knp\Bundle\TranslatorBundle\Controller\TranslatorController

API

``` php

class Knp\Bundle\TranslatorBundle\Translation\Translator extends Symfony\Bundle\FrameworkBundle\Translation\Translator
{

    public function isTranslated($id, $domain, $locale);

    public function update($id, $value, $domain, $locale);

    public function getResources($locale, $domain);

    public function getFallbackLocale();

    public function getCatalog($locale);

    public function getLocales();

    public function all();


```

Updating a given translation key is really simple:, (*26)

``` php

$this->get('translator.writer')->update('the key to translate', 'the translated string', 'messages', 'en');

```

Rest API

  • Update english translations files for domain tests with translated value for key foo.bar.baz, (*27)

    ``` bash, (*28)

    curl -X PUT http://project-url/trans/ \ -F 'id=foo.bar.baz' \ -F 'domain=messages' \ -F 'locale=en' \ -F 'value=translate value', (*29)

    ```, (*30)

  • Get the translated value of key foo.bar.baz for english locale for tests domain, (*31)

    ``` bash, (*32)

    curl http://project-url/trans/foo.bar.baz/tests/en, (*33)

    ```, (*34)

The Versions

07/08 2013

dev-master

9999999-dev

  Sources   Download