2017 © Pedro Peláez
 

symfony-bundle form-auto-translation-bundle

Bundle for autotranslate form fields

image

krombox/form-auto-translation-bundle

Bundle for autotranslate form fields

  • Wednesday, December 2, 2015
  • by krombox
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

FormAutoTranslationBundle

Add a possibility to autotranslate form fields on button click. New form type: krombox_auto_translations., (*2)

Requirements

Installation

Add the repository to your composer.json, (*3)

"krombox/form-auto-translation-bundle": "dev-master"

Run Composer to install the bundle, (*4)

php composer.phar update krombox/form-auto-translation-bundle

Add to AppKernel Register the bundle in /app/AppKernel.php:, (*5)

<?php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Krombox\FormAutoTranslationBundle\KromboxFormAutoTranslationBundle(),
            new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
            new Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle(),
            new MatthiasNoback\MicrosoftTranslatorBundle\MatthiasNobackMicrosoftTranslatorBundle()
        );
    }
}

Configuration Referance

Configure the bundle in app/config.yml:, (*6)

a2lix_translation_form:
    locale_provider: default       
    locales: [ru, en, fr, uk]     
    default_locale: en            
    required_locales: [ru, en]
    manager_registry: doctrine
    templating: "A2lixTranslationFormBundle::default.html.twig"

matthias_noback_microsoft_translator:
    oauth:
        client_id: **********************
        client_secret: *******************    

krombox_form_auto_translation:
    auto_translated_locales: [ru, en, fr, uk]
    locale_provider: default
    templating: "KromboxFormAutoTranslationBundle::default.html.twig"

Configure the bundle in app/routing.yml:, (*7)

krombox_form_auto_translation: 
    resource: "@KromboxFormAutoTranslationBundle/Resources/config/routing.yml"

Template must contains bootstrap and fontAwasome for standart way view. So, add them somehow you prefer:, (*8)

{% block stylesheets %}
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />            
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">        
{% endblock %}

Include javascripts template and init autotranslate plugin:, (*9)

{% block javascripts %}    
    {% include 'KromboxFormAutoTranslationBundle::javascripts.html.twig' %}
    <script>                                               
        $(document).ready(function(){                                                
            $('.autotranslatable').autotranslate();                                                
        });
    </script>
{% endblock %}

Use Bootsrap form theme on *.html.twig template for nice look(not necessary):, (*10)

{% form_theme form 
    'bootstrap_3_layout.html.twig'
%}

Usage

Now you can use new form type krombox_auto_translations:, (*11)

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('translations', 'krombox_auto_translations')    
        ...
    ;
}

The Versions