Download the PHP package sarcinae/api-platform-translation-bundle without Composer
On this page you can find all versions of the php package sarcinae/api-platform-translation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sarcinae/api-platform-translation-bundle
More information about sarcinae/api-platform-translation-bundle
Files in sarcinae/api-platform-translation-bundle
Package api-platform-translation-bundle
Short Description Translation bundle for Api platform based on Sylius translation
License MIT
Informations about the package api-platform-translation-bundle
Translation bundle for ApiPlatform based on Sylius translation
This is the fork of Locastic Api Translation Bundle updated for ApiPlatform 4.0
Installation:
Implementation:
Translatable entity:
- Extend your model/resource with
Sarcinae\ApiTranslationBundle\Model\AbstractTranslatable -
Add
createTranslation()method which returns new object of translation Entity. Example: -
Add a
translations-property. Add thetranslationsserializations group and make a connection to the translation entity: - Add virtual fields for all translatable fields, and add read serialization group. Getters and setters must call getters and setters from translation class. Example:
Translation entity:
- Add entity with all translatable fields. Name needs to be name of translatable entity + Translation
- Extend
Sarcinae\ApiPlatformTranslationBundle\Model\AbstractTranslation - Add serialization group
translationsto all fields and other read/write groups. Example Translation entity:
Api resource
- Add
translation.groupsfilter if you would like to have option to return all translation objects in response. If you don't usetranslationsgroup, response will return only requested locale translation or fallback locale translation. - Add translations to normalization_context for PUT and POST methods to make sure they return all translation objects.
- Example:
Usage:
Language param for displaying single translation:
?locale=de
Or use Accept-Language http header
Accept-Language: de
Serialization group for displaying all translations:
?groups[]=translations
POST translations example
EDIT translations example
All versions of api-platform-translation-bundle with dependencies
api-platform/core Version ^2.1 || ^3.0 || ^4.0
doctrine/orm Version ^3.0
doctrine/doctrine-bundle Version ^1.6 || ^2.0
symfony/translation Version *
symfony/dependency-injection Version *