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

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

Open
igorschoester opened this issue Jan 24, 2023 · 3 comments · May be fixed by #21938
Open

Comments

@igorschoester
Copy link
Member

Example from Settings' site representation:

sprintf(
	// translators: %1$s and %2$s are replaced by opening and closing <a> tags.
	__( "This info is intended to appear in %1$sGoogle's Knowledge Graph%2$s.", "wordpress-seo" ),
	"<a>",
	"</a>"
),

If the translation were to swap the %1$s and %2$s our code would error due to the invalid HTML tags (in this case Cannot read properties of undefined (reading 'prevOffset')).

Maybe we can try and prevent situations like these by only allowing ordering for actual translations and not HTML tags.
Something like %s twice for the tags would prevent this. If a translation needs both you would get some complications, I haven't thought this through. Let's investigate.

@ibanner
Copy link

ibanner commented Nov 13, 2023

Hi @igorschoester - I just got that error message after initial setup and activation of Yoast. This is a Hebrew site. It's also in development and protected by HTTP AUTH. Perhaps this is the reason?
Anyway, I'd be grateful for any tips you might have 🙏

@igorschoester
Copy link
Member Author

Hello @ibanner 👋

Indeed, the culprit seems to be the translation for:

Set the basic info for your website. You can use %1$stagline%2$s and %1$sseparator%2$s as %3$sreplacement variables%4$s when configuring the search appearance of your content.

Now as to what the correct translations should be, that is very hard to determine for me 😅 But it seems also strange with the browser seemingly switching directions mid-sentence.

A new translation would have to be submitted and approved on translate.wordpress.org before it can show up in your site's translation downloads.
Here is a link that includes a search for the above translation:
https://translate.wordpress.org/projects/wp-plugins/wordpress-seo/stable/he/default/?filters%5Bterm%5D=Set+the+basic+info+for+your+website.+You+can+use+%251%24stagline%252%24s+and+%251%24sseparator%252%24s+as+%253%24sreplacement+variables%254%24s+when+configuring+the+search+appearance+of+your+content.&filters%5Bterm_scope%5D=scope_any&filters%5Bstatus%5D=current_or_waiting_or_fuzzy_or_untranslated&filters%5Buser_login%5D=&filter=Apply+Filters&sort%5Bby%5D=priority&sort%5Bhow%5D=desc

As an example. I don't think is actually correctly highlighting the words, though at least it does not crash:

הגדר את המידע הבסיסי עבור האתר שלך. ניתן להשתמש ב-%1$sתיוג%2$sובמפריד%1$s %2$sבתור %3$s משתני החלפה%4$s בעת הגדרת מראה החיפוש של התוכן שלך.

@vraja-pro
Copy link
Contributor

Hello @ibanner I fixed the translation, you shouldn't get the error now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants