Download the PHP package locastic/api-platform-translation-bundle without Composer
On this page you can find all versions of the php package locastic/api-platform-translation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download locastic/api-platform-translation-bundle
More information about locastic/api-platform-translation-bundle
Files in locastic/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
Locastic Api Translation Bundle
Translation bundle for ApiPlatform based on Sylius translation
Installation:
Implementation:
Translatable entity:
- Extend your model/resource with
Locastic\ApiTranslationBundle\Model\AbstractTranslatable
-
Add
createTranslation()
method which returns new object of translation Entity. Example: -
Add a
translations
-property. Add thetranslations
serializations 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
Locastic\ApiPlatformTranslationBundle\Model\AbstractTranslation
- Add serialization group
translations
to all fields and other read/write groups. Example Translation entity:
Api resource
- Add
translation.groups
filter if you would like to have option to return all translation objects in response. If you don't usetranslations
group, 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
Contribution
If you have idea on how to improve this bundle, feel free to contribute. If you have problems or you found some bugs, please open an issue.
Support
Want us to help you with this bundle or any Api Platform/Symfony project? Write us an email on [email protected]
All versions of api-platform-translation-bundle with dependencies
api-platform/core Version ^2.1 || ^3.0
doctrine/orm Version ^3.0
doctrine/doctrine-bundle Version ^1.6 || ^2.0
symfony/translation Version *
symfony/dependency-injection Version *