Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ApiBundle] Unification of locale in translations #15535

Merged

Conversation

Wojdylak
Copy link
Member

Q A
Branch? 1.13
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets N?A
License MIT

@Wojdylak Wojdylak requested a review from a team as a code owner November 15, 2023 14:36
@probot-autolabeler probot-autolabeler bot added the API APIs related issues and PRs. label Nov 15, 2023
Copy link

github-actions bot commented Nov 15, 2023

Bunnyshell Preview Environment deleted

Available commands:

  • /bns:deploy to redeploy the environment

NoResponseMate
NoResponseMate previously approved these changes Nov 15, 2023
@Wojdylak Wojdylak changed the title [ApiBundle] Unification of locale in translations 🚧 [ApiBundle] Unification of locale in translations Nov 15, 2023
@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label Nov 16, 2023
@Wojdylak Wojdylak changed the title 🚧 [ApiBundle] Unification of locale in translations [ApiBundle] Unification of locale in translations Nov 16, 2023
@GSadee GSadee merged commit a3d76f0 into Sylius:1.13 Nov 16, 2023
25 checks passed
@GSadee
Copy link
Member

GSadee commented Nov 16, 2023

Thanks, Karol! 🎉

@@ -167,7 +166,7 @@ public function iWantToModifyTheProductAssociationType(ProductAssociationTypeInt
*/
public function iRenameItToIn(string $name, string $language): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--- public function iRenameItToIn(string $name, string $language): void
+++ public function iRenameItToIn(string $name, string $localeCode): void

@@ -167,7 +166,7 @@ public function iWantToModifyTheProductAssociationType(ProductAssociationTypeInt
*/
public function iRenameItToIn(string $name, string $language): void
{
$this->client->updateRequestData(['translations' => [$language => ['name' => $name, 'locale' => $language]]]);
$this->client->updateRequestData(['translations' => [$language => ['name' => $name]]]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--- $this->client->updateRequestData(['translations' => [$language => ['name' => $name]]]);
+++ $this->client->updateRequestData(['translations' => [$localeCode => ['name' => $name]]]);

@@ -61,7 +61,7 @@ public function iWantToModifyProductOption(ProductOptionInterface $productOption
*/
public function iNameItInLanguage(?string $name = null, ?string $language = 'en_US'): void
{
$data = ['translations' => [$language => ['locale' => $language]]];
$data = ['translations' => [$language => []]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--- $data = ['translations' => [$language => []]];
+++ $data = ['translations' => [$localeCode => []]];

@@ -74,15 +74,15 @@ public function iNameItInLanguage(?string $name = null, ?string $language = 'en_
*/
public function iRenameItInLanguage(string $name, string $language): void
{
$this->client->updateRequestData(['translations' => [$language => ['name' => $name, 'locale' => $language]]]);
$this->client->updateRequestData(['translations' => [$language => ['name' => $name]]]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--- $this->client->updateRequestData(['translations' => [$language => ['name' => $name]]]);
+++ $this->client->updateRequestData(['translations' => [$localeCode => ['name' => $name]]]);

}

/**
* @When I remove its name from :language translation
*/
public function iRemoveItsNameFromTranslation(string $language): void
{
$this->client->updateRequestData(['translations' => [$language => ['name' => '', 'locale' => $language]]]);
$this->client->updateRequestData(['translations' => [$language => ['name' => '']]]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

---  $this->client->updateRequestData(['translations' => [$language => ['name' => '']]]);
+++ $this->client->updateRequestData(['translations' => [$localeCode => ['name' => '']]]);


$this
->shouldThrow(TranslationLocaleMismatchException::class)
->during('denormalize', [['translations' => ['de_DE' => ['locale' => 'locale']]], TranslatableInterface::class])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As idea for more readability. (I assume test is about two valid locales mismatch)

--- ->during('denormalize', [['translations' => ['de_DE' => ['locale' => 'locale']]], TranslatableInterface::class])
+++ ->during('denormalize', [['translations' => ['de_DE' => ['locale' => 'en_US']]], TranslatableInterface::class])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks better

@Wojdylak Wojdylak deleted the SYL-3222-unification-of-locale-return-via-api branch November 30, 2023 07:57
NoResponseMate added a commit that referenced this pull request Dec 6, 2023
This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | N/A
| License         | MIT

#15535

Commits
-------
  [AttributeBundle] Add unique entity constraint to AttributeTranslation
  [PaymentBundle] Add unique entity constraint to PaymentMethodTranslation
  [ProductBundle] Add unique entity constraint to ProductAssociationTypeTranslation
  [ProductBundle] Add unique entity constraint to ProductOptionTranslation and ProductOptionValueTranslation
  [ProductBundle] Add unique entity constraint to ProductTranslation
  [ProductBundle] Add unique entity constraint to ProductVariantTranslation
  [PromotionBundle] Add unique entity constraint to CatalogPromotionTranslation
  [PromotionBundle] Add unique entity constraint to PromotionTranslation
  [ShippingBundle] Add unique entity constraint to ShippingMethodTranslation
  [TaxonBundle] Add unique entity constraint to TaxonTranslation
  [Behat] Rename language to localeCode for improved clarity
  [Api][Test] Improve spec test of throwing an exception if locale is not the same as key
  Change message of unique entity constraint of translations
  Rename unique constraint error message in translation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API APIs related issues and PRs. Maintenance CI configurations, READMEs, releases, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants