Skip to content

19701 try to come up with a solution where html tags in translations are not reliant on the order#21938

Merged
igorschoester merged 7 commits intotrunkfrom
19701-try-to-come-up-with-a-solution-where-html-tags-in-translations-are-not-reliant-on-the-order
Apr 14, 2025
Merged

19701 try to come up with a solution where html tags in translations are not reliant on the order#21938
igorschoester merged 7 commits intotrunkfrom
19701-try-to-come-up-with-a-solution-where-html-tags-in-translations-are-not-reliant-on-the-order

Conversation

@vraja-pro
Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro commented Dec 31, 2024

Context

  • We want to catch translation errors from breaking our UI.

Summary

This PR can be summarized in the following changelog entry:

  • Implements helper function to catch errors in translations.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Go to the Yoast SEO-> Settings -> Site basics -> Tagline , There should be a comment under the field:

This field updates the tagline in your WordPress settings

  • Remember that field and change to other language besides English.
  • Install the plugin Loco translate to edit your translation
  • Go to WordPress translations search for your language and choose stable version.
  • Search for the translation: "This field updates the %1$stagline in your WordPress settings%2$s."
  • Tick the translation and on the bottom of the screen you will have the option to download the translation.
  • Go to your downloads directory and rename the file by removing the the first part: wp-plugins- and it ends with the underscore and the country locale.
  • Go back the site, navigate to Loco translate->Yoast SEO, you will have a small icon to upload po file, click on it and select the file you renamed, select to location to "Custom", Make sure the name of the file matches the name as instructed above the upload button.
  • Then go back to the overview tab and edit the translation you just uploaded.
  • Search for the string "This field updates the %1$stagline in your WordPress settings%2$s."
  • Switch the placeholders and save: "This field updates the %2$stagline in your WordPress settings%1$s."
  • Go back to Yoast SEO-> Settings -> Site basics -> Tagline, look at the line under the field and check the tags are visible and there is no link: "This field updates the tagline in your WordPress settings."
  • Open dev tool and check the console has an error for that translation that starts with Error in translation for... and mention the translation and the error.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes Try to come up with a solution where HTML tags in translations are not reliant on the order

@vraja-pro vraja-pro added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Dec 31, 2024
@github-actions

This comment was marked as outdated.

3 similar comments
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 31, 2024

Pull Request Test Coverage Report for Build 91da0f367dfc4b28a114602b154580fcc70de6b1

Details

  • 0 of 6 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on 19701-try-to-come-up-with-a-solution-where-html-tags-in-translations-are-not-reliant-on-the-order at 33.37%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/settings/routes/site-basics.js 0 1 0.0%
packages/js/src/helpers/i18n.js 0 5 0.0%
Totals Coverage Status
Change from base Build 9c66956756c0900e29fb6645e4308dfb47898de1: 33.4%
Covered Lines: 2033
Relevant Lines: 5789

💛 - Coveralls

@leonidasmi leonidasmi changed the base branch from trunk to feature/plugin-fixes January 2, 2025 09:55
Copy link
Copy Markdown
Contributor

@igorschoester igorschoester left a comment

Choose a reason for hiding this comment

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

CR 🏗️

Edit: I think the changelog entries should be user facing. Maybe not the technical one that is there now. But maybe improvement that translations will now fall back to English?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As you see in the comments you got, the helpers package should not be added to.
The reason for this is that we don't want to maintain a random assortment of helpers in a helper package. If there is a need for a overarching package. You could create a specific one. The smaller and targeted, the less maintenance it needs?

Why did you add it to helpers in the first place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking it would be easier to use in the rest of the addon/premium

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Easier than what?

Copy link
Copy Markdown
Contributor Author

@vraja-pro vraja-pro Jan 14, 2025

Choose a reason for hiding this comment

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

I moved it to the helpers folder, but I'm thinking we should have a separate package or fix the issue at the source( fixing createInterpolateElement).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe. But it seems to me this is very WP plugin related. And we have API (editor-modules) to expose to our other plugins.

Comment thread packages/helpers/tests/i18nCreateInterpolateElementTest.js Outdated
Comment thread packages/helpers/tests/i18nCreateInterpolateElementTest.js Outdated
Comment thread packages/helpers/tests/i18nCreateInterpolateElementTest.js Outdated
Comment thread packages/helpers/tests/i18nCreateInterpolateElementTest.js Outdated
Comment thread packages/helpers/tests/i18nCreateInterpolateElementTest.js Outdated
Comment thread packages/helpers/src/i18n-create-interpolate-element.js Outdated
Comment thread packages/helpers/src/i18n-create-interpolate-element.js Outdated
Comment thread packages/helpers/src/i18n-create-interpolate-element.js Outdated
Comment thread packages/helpers/package.json Outdated
@igorschoester igorschoester changed the base branch from feature/plugin-fixes to trunk January 7, 2025 10:44
Also implements it in the site basic page

tests for i18nCreateInterpolateElement

fix lint

restore testURL

remove jsdom
@vraja-pro vraja-pro force-pushed the 19701-try-to-come-up-with-a-solution-where-html-tags-in-translations-are-not-reliant-on-the-order branch from 370ff4d to e258374 Compare January 14, 2025 11:34
@vraja-pro vraja-pro closed this Jan 22, 2025
@vraja-pro
Copy link
Copy Markdown
Contributor Author

Followup comment: we decided to keep it the way it is and write the translation in a way to avoid injecting tags,

@vraja-pro vraja-pro reopened this Apr 8, 2025
@vraja-pro
Copy link
Copy Markdown
Contributor Author

Temporary solution.

…-with-a-solution-where-html-tags-in-translations-are-not-reliant-on-the-order
@vraja-pro vraja-pro force-pushed the 19701-try-to-come-up-with-a-solution-where-html-tags-in-translations-are-not-reliant-on-the-order branch from 29158da to ee859f8 Compare April 8, 2025 11:44
Copy link
Copy Markdown
Contributor

@igorschoester igorschoester left a comment

Choose a reason for hiding this comment

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

CR && AT ✅

Though I did not manage to get the Loco translation thing working. I just adapted the source string to be reversed already 😉

I'm holding of merging for now, as I'm not sure about our plan for implementation? This is just adding it in one location anyway. Slack question

@igorschoester
Copy link
Copy Markdown
Contributor

Ok, can be merged. More follow-up needed and created this issue to keep track of that

@igorschoester igorschoester added this to the 25.0 milestone Apr 14, 2025
@igorschoester igorschoester merged commit 436e0fd into trunk Apr 14, 2025
18 checks passed
@igorschoester igorschoester deleted the 19701-try-to-come-up-with-a-solution-where-html-tags-in-translations-are-not-reliant-on-the-order branch April 14, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Try to come up with a solution where HTML tags in translations are not reliant on the order

3 participants