#51893 closed defect (bug) (fixed)
Don’t split translatable strings in block templates
Reported by: | tobifjellner | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | 5.5 |
Component: | Editor | Keywords: | has-patch i18n-change commit dev-reviewed |
Focuses: | Cc: |
Description
WordPress RC 1 contains a couple of strings that are almost impossible to translate well without specifically figuring out how the underlying code is created.
The reason is:
Thou shalt never
split a sentence in two parts and then glue them together again after translation.
But that is exactly what happens now in:
https://build.trac.wordpress.org/browser/branches/5.6/wp-includes/block-patterns/large-header-button.php?marks=10#L10
Code excerpt:
<strong>" . __( 'Thou hast seen' ) . '</strong><br><strong>' . __( 'nothing yet' ) . "</strong></p>
Some examples of why this is a problem:
- German word order would typically put the verb at the end of the sentence.
- In Swedish, the best translation would split out the negation (from string 2) and put it next to the verb.
- etcetera.
Even if the translator knows exactly how these strings are used, you still have the problem that somewhere else you might have, say, a result of a search operation that says "nothing yet". Imagine the German translation suddenly having an unexpected verb there, or the Swedish translation actually lacking the "no"...
If you necessarily need to split a sentence that should be translated as a whole as two or more separate chunks, then you MUST use _x() and in the context string lock this partial translation to this particular case.
But the best way to handle is to include the whole sentence in the string. If you, due to technical limitations, can't allow tags in the translated string then we need to find a workaround. But a few formatting tags or br-tags in the string to be translated is totally OK, and much-much better than this kind of magical brewery.
H/t @kebbet who alarmed me about this problem. I'll upload his example from his test run of the Swedish translation in use.
During translation, the Victorian-sounding "Thou" prompted me to just keep the English text, since I had no clue how it was to be used. But the other string "nothing yet" is totally normal, and thus got translated...
Attachments (5)
Change History (23)
This ticket was mentioned in Slack in #core-editor by tobifjellner. View the logs.
4 years ago
#3
@
4 years ago
Thanks for the report!
Looks like this is not a regression in 5.6 RC1 though, the strings were added in [48639] / #50550 for WP 5.5.
I think the string could just be replaced with __( 'Thou hast seen<br> nothing yet' )
.
This also needs to be fixed upstream in Gutenberg. Some previous examples:
- #50842, which was a backport of https://github.com/WordPress/gutenberg/pull/24317 for #GB24316.
- #50845, which was a backport of https://github.com/WordPress/gutenberg/pull/24647 for #GB24646.
#5
follow-up:
↓ 7
@
4 years ago
Oh. Due to a browser bug (?), I didn't see the comments above before uploading my patch.
By the way, the above patch keeps the current markup. The string becomes:
<strong>Thou hast seen</strong><br><strong>nothing yet</strong>
#6
@
4 years ago
- Keywords has-patch i18n-change added
- Summary changed from Block editor: Serious i18n flaw in block patterns for WP 5.6 to Don’t split translatable strings in block templates
#7
in reply to:
↑ 5
@
4 years ago
Replying to audrasjb:
By the way, the above patch keeps the current markup. The string becomes:
<strong>Thou hast seen</strong><br><strong>nothing yet</strong>
Is there a difference in display between that and the <strong>
tags outside of the string?
'<strong>' . __( 'Thou hast seen<br> nothing yet' ) . '</strong>'
I'd like to keep the string as simple as possible :)
#8
@
4 years ago
51893.patch patch remove <br>
tag from string and change font size to adjust the text in two lines
#9
follow-up:
↓ 11
@
4 years ago
@SergeyBiryukov you're right :) 51893.2.diff
moves <strong> tags outside of the translatable string.
@mukesh27 the <br /> tag is here by design, I wouldn't touch it without asking the design team. Better to keep it as it is now.
#10
@
4 years ago
- Keywords commit added
51893.2.diff looks good to me :)
Let's also patch this upstream in Gutenberg, the file that needs changing is here:
https://github.com/WordPress/gutenberg/blob/master/lib/patterns/large-header-button.php
#11
in reply to:
↑ 9
@
4 years ago
Yup. 51893.2.diff looks good to me.
Replying to audrasjb:
@SergeyBiryukov you're right :)
51893.2.diff
moves <strong> tags outside of the translatable string.
@mukesh27 the <br /> tag is here by design, I wouldn't touch it without asking the design team. Better to keep it as it is now.
#12
@
4 years ago
PR opened upstream: https://github.com/WordPress/gutenberg/pull/27361
#13
@
4 years ago
- Owner set to audrasjb
- Status changed from new to accepted
Merged in Gutenberg: https://github.com/WordPress/gutenberg/pull/27361
We're waiting for a second committer sign-off.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 years ago
#15
@
4 years ago
- Keywords dev-reviewed added
51893.2.diff looks good here too. +1 to commit to the 5.6 branch.
Swedish test run of WP 5.6 RC1