{"id":21862011,"url":"https://github.com/softspring/doctrine-simple-translation-type-bundle","last_synced_at":"2025-04-14T19:40:50.079Z","repository":{"id":57055007,"uuid":"217408568","full_name":"softspring/doctrine-simple-translation-type-bundle","owner":"softspring","description":"This package provides a simple translation type for doctrine using JSON type.","archived":false,"fork":false,"pushed_at":"2025-03-24T13:11:13.000Z","size":44,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"5.3","last_synced_at":"2025-03-28T08:03:04.356Z","etag":null,"topics":["component","doctrine","symfony-bundle"],"latest_commit_sha":null,"homepage":"","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/softspring.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":"2019-10-24T22:49:54.000Z","updated_at":"2025-01-14T16:06:22.000Z","dependencies_parsed_at":"2023-01-31T08:31:22.068Z","dependency_job_id":"f5298f81-3d71-42d9-96fb-85e71a8a0eff","html_url":"https://github.com/softspring/doctrine-simple-translation-type-bundle","commit_stats":{"total_commits":36,"total_committers":3,"mean_commits":12.0,"dds":"0.16666666666666663","last_synced_commit":"4007cf971079c5d6bb11209c3fd5a1275274bf51"},"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softspring%2Fdoctrine-simple-translation-type-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softspring%2Fdoctrine-simple-translation-type-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softspring%2Fdoctrine-simple-translation-type-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softspring%2Fdoctrine-simple-translation-type-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softspring","download_url":"https://codeload.github.com/softspring/doctrine-simple-translation-type-bundle/tar.gz/refs/heads/5.3","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248948178,"owners_count":21187825,"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":["component","doctrine","symfony-bundle"],"created_at":"2024-11-28T03:13:22.960Z","updated_at":"2025-04-14T19:40:50.068Z","avatar_url":"https://github.com/softspring.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doctrine simple translation type bundle\n\n![Latest Stable](https://img.shields.io/packagist/v/softspring/doctrine-simple-translation-type-bundle?label=stable\u0026style=flat-square)\n![Latest Unstable](https://img.shields.io/packagist/v/softspring/doctrine-simple-translation-type-bundle?label=unstable\u0026style=flat-square\u0026include_prereleases)\n![License](https://img.shields.io/packagist/l/softspring/doctrine-simple-translation-type-bundle?style=flat-square)\n![PHP Version](https://img.shields.io/packagist/dependency-v/softspring/doctrine-simple-translation-type-bundle/php?style=flat-square)\n![Downloads](https://img.shields.io/packagist/dt/softspring/doctrine-simple-translation-type-bundle?style=flat-square)\n[![CI](https://img.shields.io/github/actions/workflow/status/softspring/doctrine-simple-translation-type-bundle/ci.yml?branch=5.3\u0026style=flat-square\u0026label=CI)](https://github.com/softspring/doctrine-simple-translation-type-bundle/actions/workflows/ci.yml)\n\nThis package provides a simple translation type for Doctrine, and its Symfony integration bundle.\n\n## Installation\n\n### Applications that use Symfony Flex\n\nOpen a command console, enter your project directory and execute:\n\n```console\n$ composer require softspring/doctrine-simple-translation-type-bundle\n```\n\n## Configure\n\nConfigure the Doctrine type:\n\n    # config/packages/doctrine.yaml\n    \n    doctrine:\n        dbal:\n            types:\n                simple_translation: 'Softspring\\DoctrineSimpleTranslationTypeBundle\\Doctrine\\Type\\SimpleTranslationType'\n\n## Usage\n\n### Configure entity that uses the type\n\n    use Doctrine\\ORM\\Mapping as ORM;\n\n    /**\n     * @var SimpleTranslation\n     * @ORM\\Column(name=\"translated_name\", type=\"simple_translation\", nullable=false)\n     */\n    protected $translatedName;\n    \n    public function __construct()\n    {\n        $this-\u003etranslatedName = new SimpleTranslation();\n    }\n                \n    /**\n     * @return SimpleTranslation\n     */\n    public function getName(): SimpleTranslation\n    {\n        return $this-\u003etranslatedName;\n    }\n\n    /**\n     * @param SimpleTranslation $translatedName\n     */\n    public function setName(SimpleTranslation $translatedName): void\n    {\n        $this-\u003etranslatedName = $translatedName;\n    }   \n    \n### Manage the model\n\nThe model class is *Softspring\\DoctrineSimpleTranslationTypeBundle\\Model\\SimpleTranslation*.\n\n**Set the default translation**\n\n    $entity-\u003egetName()-\u003esetDefaultLocale('es');\n    $entity-\u003egetName()-\u003esetTranslation(null, 'Nombre de la entidad'); // null means default locale\n    $entity-\u003egetName()-\u003esetTranslation('es', 'Nombre de la entidad'); // it's also posible to specify the locale\n    \n**Add additional translations**\n\n    $entity-\u003egetName()-\u003esetTranslation('en', 'Entity name');\n    \n**Get the value**\n    \n    $entity-\u003egetName()-\u003etranslate(); // returns the default value 'Nombre de la entidad'\n    $entity-\u003egetName()-\u003etranslate('es'); // returns 'Nombre de la entidad'\n    $entity-\u003egetName()-\u003etranslate('en'); // returns 'Entity name'\n    \n**Use the full methods**\n\n    $entity-\u003egetName()-\u003egetTranslations(); // returns ['es'=\u003e'Nombre de la entidad', 'en'=\u003e'Entity name']\n    $entity-\u003egetName()-\u003esetTranslations(['es'=\u003e'Nombre de la entidad', 'en'=\u003e'Entity name']);\n    \n**Use it as array**\n\nThe model implements ArrayAccess, so it's possible to use it as an array:\n\n    $entity-\u003egetName()['en']; // returns 'Entity name'\n    $entity-\u003egetName()['es']; // returns 'Nombre de la entidad'\n    \n### Twig usage\n\n    {{ entity.name|translate }} {# returns 'Nombre de la entidad' if app.request.locale is 'es' #}    \n    {{ entity.name|translate('es') }} {# returns 'Nombre de la entidad' #}    \n    {{ entity.name|translate('en') }} {# returns 'Entity name' #}    \n\n### Edit values in forms\n\nYou can use the *Softspring\\DoctrineSimpleTranslationTypeBundle\\Form\\SimpleTranslationType*\n\n    use Symfony\\Component\\Form\\FormBuilderInterface;\n    \n    public function buildForm(FormBuilderInterface $builder, array $options)\n    {\n        $builder-\u003eadd('translatedName'); // automatically uses the SimpleTranslationType thanks to the TypeGuesser\n    }\n    \n**Force languages**\n\n    $builder-\u003eadd('translatedName', SimpleTranslationType::class, [\n        'languages' =\u003e ['es','en','de'],    \n    ]);\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftspring%2Fdoctrine-simple-translation-type-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftspring%2Fdoctrine-simple-translation-type-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftspring%2Fdoctrine-simple-translation-type-bundle/lists"}