Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6336f64
commit 9c3ef8f
Showing
30 changed files
with
1,141 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
Feature: Use default translation for a resource if available | ||
In order to translate API resources | ||
As a client software developer | ||
The API should return translated fields for a given locale | ||
|
||
@createSchema | ||
Scenario: A resource is translated for a given locale | ||
Given there is a translatable dummy with its translations | ||
When I send a "GET" request to "/dummy_translatables" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON node "hydra:member[0].name" should be equal to "Dummy translated in English" | ||
And the JSON node "hydra:member[0].description" should be equal to "It's a dummy!" | ||
When I send a "GET" request to "/dummy_translatables/fr" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON node "hydra:member[0].name" should be equal to "Dummy traduit en français" | ||
And the JSON node "hydra:member[0].description" should be equal to "C'est un dummy !" | ||
And the JSON node "hydra:member[0].notTranslatedField" should be equal to "not translated" | ||
|
||
Scenario: A translation can be updated for a resource | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "PUT" request to "/dummy_translatables/1/fr" with body: | ||
""" | ||
{ | ||
"name": "Dummy mieux traduit en français", | ||
"notTranslatedField": "really not translated" | ||
} | ||
""" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON node "name" should be equal to "Dummy mieux traduit en français" | ||
And the JSON node "description" should be equal to "C'est un dummy !" | ||
And the JSON node "notTranslatedField" should be equal to "really not translated" | ||
When I send a "GET" request to "/dummy_translatables/fr" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON node "hydra:member[0].name" should be equal to "Dummy mieux traduit en français" | ||
And the JSON node "hydra:member[0].description" should be equal to "C'est un dummy !" | ||
And the JSON node "hydra:member[0].notTranslatedField" should be equal to "really not translated" | ||
|
||
Scenario: A translation can be added to a resource | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "PUT" request to "/dummy_translatables/1/es" with body: | ||
""" | ||
{ | ||
"name": "Dummy traducido al español", | ||
"description": "¡Es un dummy!", | ||
"notTranslatedField": "truly not translated" | ||
} | ||
""" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON node "name" should be equal to "Dummy traducido al español" | ||
And the JSON node "description" should be equal to "¡Es un dummy!" | ||
And the JSON node "notTranslatedField" should be equal to "truly not translated" | ||
When I send a "GET" request to "/dummy_translatables/es" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON node "hydra:member[0].name" should be equal to "Dummy traducido al español" | ||
And the JSON node "hydra:member[0].description" should be equal to "¡Es un dummy!" | ||
And the JSON node "hydra:member[0].notTranslatedField" should be equal to "truly not translated" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Bridge/Symfony/Bundle/Resources/config/translation.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="api_platform.translation.resource_translator" class="ApiPlatform\Core\Translation\ResourceTranslator" public="false"> | ||
<argument type="service" id="request_stack" /> | ||
<argument type="service" id="api_platform.property_accessor" /> | ||
<argument type="service" id="api_platform.metadata.resource.metadata_factory" /> | ||
</service> | ||
<service id="ApiPlatform\Core\Translation\ResourceTranslatorInterface" alias="api_platform.translation.resource_translator" /> | ||
</services> | ||
|
||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.