{"id":23115369,"url":"https://github.com/sonofwinter/translationbundle","last_synced_at":"2025-07-23T21:04:33.928Z","repository":{"id":57055859,"uuid":"133259128","full_name":"SonOfWinter/TranslationBundle","owner":"SonOfWinter","description":"A Symfony 4/5 bundle to translate an entity","archived":false,"fork":false,"pushed_at":"2023-09-20T13:05:47.000Z","size":82,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T12:43:09.559Z","etag":null,"topics":["php7","php8","symfony-bundle","symfony4","symfony5","translation"],"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/SonOfWinter.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":"2018-05-13T17:25:08.000Z","updated_at":"2023-09-19T16:00:33.000Z","dependencies_parsed_at":"2025-02-10T06:01:16.638Z","dependency_job_id":null,"html_url":"https://github.com/SonOfWinter/TranslationBundle","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonOfWinter%2FTranslationBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonOfWinter%2FTranslationBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonOfWinter%2FTranslationBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonOfWinter%2FTranslationBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SonOfWinter","download_url":"https://codeload.github.com/SonOfWinter/TranslationBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103307,"owners_count":20884023,"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":["php7","php8","symfony-bundle","symfony4","symfony5","translation"],"created_at":"2024-12-17T03:40:50.992Z","updated_at":"2025-07-23T21:04:33.908Z","avatar_url":"https://github.com/SonOfWinter.png","language":"PHP","readme":"# SOWTranslationBundle\n\nThis Bundle provides a translator for Symfony entities.\n\n## Prerequisites\n\n- PHP 8.2 or higher\n- Symfony 7.0 or higher\n- Composer\n\n## Installation\n\nOpen a command console, enter your project directory and execute:\n\n```bash\n$ composer require sonofwinter/translation-bundle\n```\n\n## Configuration\n\n### Bundle Registration\n\nRegister the bundle in your `config/bundles.php`:\n\n```php\nreturn [\n    // ...\n    SOW\\TranslationBundle\\SOWTranslationBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n### Available Locales\n\nYou can override the default available locales by setting the `sow_translation.available_locales` parameter:\n\n```yaml\nparameters:\n    sow_translation.available_locales: ['en', 'fr', 'es', 'de', 'it']\n```\n\n### Custom Translation Entity\n\nBy default, a Translation entity class is provided, but you can create your own translation entity class that extends AbstractTranslation.\nTo use it, set the `sow_translation.translation_class_name` parameter:\n\n```yaml\nparameters:\n    sow_translation.translation_class_name: App\\Entity\\YourTranslationClass\n```\n\n## Usage\n\n### Setting Up Translatable Entities\n\nYour translated entities must implement the `Translatable` interface.\nThen define translated properties in your entity using either annotations or attributes.\n\n#### Using Attributes (PHP 8.0+)\n\n```php\nuse SOW\\TranslationBundle\\Attribute\\Translation;\n\nclass MyClass {\n    #[Translation(key: \"firstname\")]\n    private string $firstname = '';\n\n    #[Translation(key: \"lastname\", setter: \"setOtherName\")]\n    private string $lastname = '';\n}\n```\n\n### Configuration Notes\n\n- The `key` property can be used to specify a different name for the translation key. If not provided, the property name is used.\n- The `setter` property allows you to specify a custom setter method. If the setter doesn't exist, a `TranslatableConfigurationException` will be thrown.\n\n## Translation Methods\n\n### Translating Entities\n\n```php\n// Translate an entity to a specific language\n$translator-\u003etranslate($entity, 'en');\n\n// Translate an entity to multiple languages\n$translator-\u003etranslateForLangs($entity, ['en', 'fr', 'de']);\n```\n\n### Setting Translations\n\n```php\n// Set a single translation\n$translator-\u003esetTranslationForLangAndValue($entity, 'en', 'firstname', 'John');\n\n// Set multiple values for one language\n$translator-\u003esetTranslationForLangAndValues($entity, 'en', [\n    'firstname' =\u003e 'John',\n    'lastname' =\u003e 'Doe'\n]);\n\n// Set multiple translations for multiple languages\n$translator-\u003esetTranslations($entity, [\n    'en' =\u003e [\n        'firstname' =\u003e 'John',\n        'lastname' =\u003e 'Doe'\n    ],\n    'fr' =\u003e [\n        'firstname' =\u003e 'Jean',\n        'lastname' =\u003e 'Dupont'\n    ]\n]);\n```\n\n### Removing Translations\n\n```php\n// Remove a specific translation\n$translator-\u003eremoveByObjectKeyAndLang($entity, 'firstname', 'en');\n\n// Remove all translations for an entity\n$translator-\u003eremoveAllForTranslatable($entity);\n\n// Remove all translations for a specific key\n$translator-\u003eremoveAllByKey('firstname');\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonofwinter%2Ftranslationbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonofwinter%2Ftranslationbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonofwinter%2Ftranslationbundle/lists"}