{"id":14983951,"url":"https://github.com/a2lix/translationformbundle","last_synced_at":"2025-04-11T11:46:52.844Z","repository":{"id":3750199,"uuid":"4825482","full_name":"a2lix/TranslationFormBundle","owner":"a2lix","description":"Ease translations with some dedicated Symfony form types","archived":false,"fork":false,"pushed_at":"2024-07-02T17:37:39.000Z","size":399,"stargazers_count":331,"open_issues_count":12,"forks_count":138,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-03T12:06:55.537Z","etag":null,"topics":["bundle","doctrine","php","symfony","symfony-bundle","symfony-form","translation"],"latest_commit_sha":null,"homepage":"https://a2lix.fr/bundles/translation-form","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a2lix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-06-28T20:51:50.000Z","updated_at":"2025-03-08T07:44:16.000Z","dependencies_parsed_at":"2023-07-06T01:45:59.326Z","dependency_job_id":"274c5d61-c09b-43ee-b333-1f4a8aa025a6","html_url":"https://github.com/a2lix/TranslationFormBundle","commit_stats":{"total_commits":234,"total_committers":51,"mean_commits":4.588235294117647,"dds":0.594017094017094,"last_synced_commit":"4ec3165887c03040aa89c8d2012978c24c0dc25d"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2lix%2FTranslationFormBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2lix%2FTranslationFormBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2lix%2FTranslationFormBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2lix%2FTranslationFormBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a2lix","download_url":"https://codeload.github.com/a2lix/TranslationFormBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248388213,"owners_count":21095354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","doctrine","php","symfony","symfony-bundle","symfony-form","translation"],"created_at":"2024-09-24T14:08:13.805Z","updated_at":"2025-04-11T11:46:52.815Z","avatar_url":"https://github.com/a2lix.png","language":"PHP","readme":"# A2lix Translation Form Bundle\n\nTranslate your doctrine objects easily with some helps\n\n[![Latest Stable Version](https://poser.pugx.org/a2lix/translation-form-bundle/v/stable)](https://packagist.org/packages/a2lix/translation-form-bundle)\n[![Latest Unstable Version](https://poser.pugx.org/a2lix/translation-form-bundle/v/unstable)](https://packagist.org/packages/a2lix/translation-form-bundle)\n[![License](https://poser.pugx.org/a2lix/translation-form-bundle/license)](https://packagist.org/packages/a2lix/translation-form-bundle)\n\n[![Total Downloads](https://poser.pugx.org/a2lix/translation-form-bundle/downloads)](https://packagist.org/packages/a2lix/translation-form-bundle)\n[![Monthly Downloads](https://poser.pugx.org/a2lix/translation-form-bundle/d/monthly)](https://packagist.org/packages/a2lix/translation-form-bundle)\n[![Daily Downloads](https://poser.pugx.org/a2lix/translation-form-bundle/d/daily)](https://packagist.org/packages/a2lix/translation-form-bundle)\n\n| Branch | Tools |\n| --- | --- |\n| 3.x (master) | [![Build Status][v3_ci_badge]][v3_ci_link] [![Coverage Status][v3_coverage_badge]][v3_coverage_link] |\n\n## Screenshot example\n\n![A2LiX Translation Form Screenshot](/a2lix_translationForm.jpg)\n\n## Support\n\n* `3.x` depends on [AutoFormBundle](https://github.com/a2lix/AutoFormBundle) and has higher requirements (PHP8.1+, Symfony5.4+/6.3+/7.0+). It is compatible with [KnpLabs](https://github.com/KnpLabs/DoctrineBehaviors#translatable), [A2lix](https://github.com/a2lix/I18nDoctrineBundle) and [Prezent](https://github.com/Prezent/doctrine-translatable-bundle)\n\n## Installation\n\nUse composer:\n\n```bash\ncomposer require a2lix/translation-form-bundle\n```\n\nAfter the successful installation, add/check the bundle registration:\n\n```php\n// Symfony \u003e= 4.0 in bundles.php\n// ...\nA2lix\\AutoFormBundle\\A2lixAutoFormBundle::class =\u003e ['all' =\u003e true],\nA2lix\\TranslationFormBundle\\A2lixTranslationFormBundle::class =\u003e ['all' =\u003e true],\n// ...\n\n// Symfony \u003e= 3.4 in AppKernel::registerBundles()\n$bundles = array(\n// ...\nnew A2lix\\AutoFormBundle\\A2lixAutoFormBundle(),\nnew A2lix\\TranslationFormBundle\\A2lixTranslationFormBundle(),\n// ...\n```\n\n## Configuration\n\nThere is no minimal configuration. Full list of optional parameters:\n\n```yaml\n# Symfony \u003e= 4.0. Create a dedicated a2lix.yaml in config/packages with:\n# Symfony \u003e= 3.4. Add in your app/config/config.yml:\n\na2lix_translation_form:\n    locale_provider: default       # [1]\n    locales: [en, fr, es, de]      # [1-a]\n    default_locale: en             # [1-b]\n    required_locales: [fr]         # [1-c]\n    templating: \"@A2lixTranslationForm/bootstrap_4_layout.html.twig\"      # [2]\n```\n\n1. Custom locale provider service id. Default one relies on [1-*] values:\n   - [1-a] List of translations locales to display\n   - [1-b] Default locale\n   - [1-c] List of required translations locales\n2. The default template is Twitter Bootstrap compatible. You can redefine your own here\n\n## Usage\n\n### In a classic formType\n\n```php\nuse A2lix\\TranslationFormBundle\\Form\\Type\\TranslationsType;\n...\n$builder-\u003eadd('translations', TranslationsType::class);\n```\n\n### Advanced examples\n\n```php\nuse A2lix\\TranslationFormBundle\\Form\\Type\\TranslationsType;\n...\n$builder-\u003eadd('translations', TranslationsType::class, [\n    'locales' =\u003e ['en', 'fr', 'es', 'de'],   // [1]\n    'default_locale' =\u003e ['en'],              // [1]\n    'required_locales' =\u003e ['fr'],            // [1]\n    'fields' =\u003e [                               // [2]\n        'description' =\u003e [                         // [3.a]\n            'field_type' =\u003e 'textarea',                // [4]\n            'label' =\u003e 'descript.',                    // [4]\n            'locale_options' =\u003e [                  // [3.b]\n                'es' =\u003e ['label' =\u003e 'descripción'],    // [4]\n                'fr' =\u003e ['display' =\u003e false]           // [4]\n            ]\n        ]\n    ],\n    'excluded_fields' =\u003e ['details'],           // [2]\n    'locale_labels' =\u003e [                        // [5]\n        'fr' =\u003e 'Français',\n        'en' =\u003e 'English',\n    ],\n]);\n```\n\n1. Optional. If set, override the default value from config.yml\n2. Optional. If set, override the default value from config.yml\n3. Optional. If set, override the auto configuration of fields\n   - [3.a] Optional. - For a field, applied to all locales\n   - [3.b] Optional. - For a specific locale of a field\n4. Optional. Common options of symfony forms (max_length, required, trim, read_only, constraints, ...), which was added 'field_type' and 'display'\n5. Optional. Set the labels for the translation tabs. Default to the name of the locale. Translation keys can be used here.\n\n## Additional\n\n### TranslationsFormsType\n\nA different approach for entities which don't share fields untranslated. No strategy used here, only a locale field in your entity.\n\n```php\nuse A2lix\\TranslationFormBundle\\Form\\Type\\TranslationsFormsType;\n...\n$builder-\u003eadd('translations', TranslationsFormsType::class, [\n    'locales' =\u003e ['en', 'fr', 'es', 'de'],   // [1]\n    'default_locale' =\u003e ['en']               // [1]\n    'required_locales' =\u003e ['fr'],            // [1]\n    'form_type' =\u003e ProductMediaType::class,     // [2 - Mandatory]\n    'form_options' =\u003e [                         // [2bis]\n         'context' =\u003e 'pdf'\n    ]\n]);\n```\n\n1. Optional. If set, override the default value from config.yml\n2. Mandatory. A real form type that you have to do\n   - [2bis] Optional. - An array of options that you can set to your form\n\n### TranslatedEntityType\n\nModified version of the native 'entity' symfony form type to translate the label in the current locale by reading translations\n\n```php\nuse A2lix\\TranslationFormBundle\\Form\\Type\\TranslatedEntityType;\n...\n$builder-\u003eadd('medias', TranslatedEntityType::class, [\n    'class' =\u003e 'A2lix\\DemoTranslationBundle\\Entity\\Media',   // [1 - Mandatory]\n    'translation_property' =\u003e 'title',                           // [2 - Mandatory]\n    'multiple' =\u003e true,                                             // [3]\n]);\n```\n\n1. Path of the translatable class\n2. Property/Method of the translatable class that will be display\n3. Common options of the 'entity' Symfony form type (multiple, ...)\n\n### Example\n\nSee [Demo Bundle](https://github.com/a2lix/Demo) for more examples.\n\n\n## Contribution help\n\n```\ndocker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer install --ignore-platform-reqs\ndocker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer run-script phpunit\ndocker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer run-script cs-fixer\n```\n\n## License\n\nThis package is available under the [MIT license](LICENSE).\n\n[v3_ci_badge]: https://github.com/a2lix/TranslationFormBundle/actions/workflows/ci.yml/badge.svg\n[v3_ci_link]: https://github.com/a2lix/TranslationFormBundle/actions/workflows/ci.yml\n[v3_coverage_badge]: https://codecov.io/gh/a2lix/TranslationFormBundle/branch/master/graph/badge.svg\n[v3_coverage_link]: https://codecov.io/gh/a2lix/TranslationFormBundle/branch/master\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa2lix%2Ftranslationformbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa2lix%2Ftranslationformbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa2lix%2Ftranslationformbundle/lists"}