krombox / form-auto-translation-bundle
Bundle for autotranslate form fields
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.4
- a2lix/translation-form-bundle: ^2.0
- doctrine/doctrine-bundle: ~1.4
- doctrine/orm: ~2.4
- knplabs/doctrine-behaviors: ~1.1
- matthiasnoback/microsoft-translator-bundle: ~0.2
- symfony/monolog-bundle: ~2.4
- symfony/twig-bundle: ~2.3
- twig/extensions: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.3
- symfony/framework-bundle: >=2.1,<2.4-dev
This package is not auto-updated.
Last update: 2024-12-25 18:27:47 UTC
README
FormAutoTranslationBundle
Add a possibility to autotranslate form fields on button click. New form type: krombox_auto_translations
.
Requirements
- PHP <=5.4
- Symfony 2.3
- KnpLabs/DoctrineBehaviors(auto installed from composer)
- A2lixTranslationFormBundle(auto installed from composer)
- MicrosoftTranslatorBundle (auto installed from composer)
Installation
Add the repository to your composer.json
"krombox/form-auto-translation-bundle": "dev-master"
Run Composer to install the bundle
php composer.phar update krombox/form-auto-translation-bundle
Add to AppKernel
Register the bundle in /app/AppKernel.php
:
<?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
:
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
:
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:
{% 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:
{% 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):
{% form_theme form
'bootstrap_3_layout.html.twig'
%}
##Usage
Now you can use new form type krombox_auto_translations
:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('translations', 'krombox_auto_translations')
...
;
}