Download the PHP package sonofwinter/translation-bundle without Composer
On this page you can find all versions of the php package sonofwinter/translation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sonofwinter/translation-bundle
More information about sonofwinter/translation-bundle
Files in sonofwinter/translation-bundle
Package translation-bundle
Short Description This Bundle provides a translator from Entity
License MIT
Informations about the package translation-bundle
TranslationBundle
Installation
Open a command console, enter your project directory and execute:
Configuration
You can override sow_translation.availablelocales parameter to a new list for set your available lang list default is [ 'en', 'fr', 'es', 'de', 'it' ]_
By default a Translation entity class exists but you can create your translation entity class who extends AbstractTranslation To use it, set the sow_translation.translation_class_name parameter to
Usage
Your translated entities must implements Translatable interface Then define translated properties in your entity
You can defined the key property for matching another name, if it's not, the property name is taken by default. The setter property is used if you want to use another setter. A TranslatableConfigurationException is throws if the setter doens't exist.
New n V0.8
This bundle now require php >= 8.0
you can use attribute instead of annotation
By default, the bundle use annotation method, you have to change configuration to use attributes
If you want to override attribute class, don't forget to define it in configuration
Translate
You can use some methods for translate an entity :
- translate(Translatable $entity, string $lang) to translate the entity in $lang
- translateForLangs(Translatable $entity, array $langs) to translate the entity in multiple languages
Set translations
These methods is use for set translations :
- setTranslationForLangAndValue(Translatable $translatable, string $lang, string $key, string $value) to set a single translation
- setTranslationForLangAndValues(Translatable $translatable, string $lang, array $values) for set multiple values in one lang
- setTranslations(Translatable $translatable, array $translations) for set multiple translation for multiple languages
Remove translations
These methods is use for remove translations :
- removeByObjectKeyAndLang(Translatable $object, string $key, string $lang) remove a specific translation
- removeAllForTranslatable(Translatable $object) remove all translation for object
- removeAllByKey(string $key) remove all translation for property
All versions of translation-bundle with dependencies
symfony/framework-bundle Version ^6.0
symfony/orm-pack Version *
symfony/dependency-injection Version ^6.0
symfony/yaml Version ^6.0
doctrine/annotations Version ^2.0