#60298 closed defect (bug) (fixed)
Text embedded in theme template is not translatable
Reported by: | wildworks | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Bundled Theme | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Related to an issue reported on Gutenberg: https://github.com/WordPress/gutenberg/issues/55983
Default block themes embed some text inside the template as content or attributes. However, template files are HTML files and cannot use PHP translation functions like pattern files. As a result, English will always be displayed, even if the user changes the site language.
As far as I've researched, the following passages are untranslatable text.
Twenty Twenty-Three
Newer Posts
:Older Posts
:Mindblown: a blog about philosophy.
: home.html, line 6
Twenty Twenty-Four
Posts
: index.html, line 6
Attachments (1)
Change History (43)
#2
@
8 months ago
Twenty Twenty-Four, patterns/footer.php, in the footer menu fallbacks, the labels are not translatable.
Props @onemaggie, @luminuu
<!-- wp:navigation-link {"label":"Team","url":"#"} /--> <!-- wp:navigation-link {"label":"History","url":"#"} /--> <!-- wp:navigation-link {"label":"Careers","url":"#"} /--> <!-- wp:navigation-link {"label":"Privacy Policy","url":"#"} /--> <!-- wp:navigation-link {"label":"Terms and Conditions","url":"#"} /--> <!-- wp:navigation-link {"label":"Contact Us","url":"#"} /--> <!-- wp:navigation-link {"label":"Facebook","url":"#"} /--> <!-- wp:navigation-link {"label":"Instagram","url":"#"} /--> <!-- wp:navigation-link {"label":"Twitter/X","url":"#"} /-->
#4
follow-up:
↓ 18
@
7 months ago
The texts "Newer Posts" and "Older Posts" are in the query pagination block.
This block requires a parent query loop block, so it can't be placed alone in a pattern file to add the translation.
We can either:
- Wait for the block editor / Gutenberg to support
ancestor
in the query pagination block, and create patterns with only the pagination: https://github.com/WordPress/gutenberg/issues/38684 - Create patterns for the query
- Remove the text strings and use the defaults: Previous Page and Next Page. This would be a change on live sites where the user has not customized their templates.
For the single headings that are not translatable we could create very small patterns, that are hidden from the block inserter. But I would like to hear some more opinions about if this is really the best practise.
This ticket was mentioned in PR #6012 on WordPress/wordpress-develop by @poena.
7 months ago
#5
- Keywords has-patch added; needs-patch removed
Updates text labels in footer.php.
Trac ticket:
https://core.trac.wordpress.org/ticket/60298
@mukesh27 commented on PR #6012:
7 months ago
#8
@carolinan The changes look good. Are you going to open PR for Twenty Twenty-Three?
7 months ago
#9
@carolinan The changes look good. Are you going to open PR for Twenty Twenty-Three?
Not right now, I ran into problems withe upstreams Gutenberg PR.
#10
@
7 months ago
- Keywords commit added
Could we commit the change to footer.php in Twenty twenty-Four, and then re-open the issue for the remaining text strings?
#11
@
7 months ago
- Keywords has-patch added; needs-patch removed
- Owner set to audrasjb
- Status changed from new to accepted
Yeah sounds good to me @poena let's handle this theme by theme.
I'll commit the TT4 PR right now.
#13
@
7 months ago
- Keywords needs-patch added; commit has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening to address the other missing text labels.
@audrasjb commented on PR #6012:
7 months ago
#14
committed in https://core.trac.wordpress.org/changeset/57588
This ticket was mentioned in Slack in #core-themes by karmatosed. View the logs.
5 months ago
This ticket was mentioned in PR #6403 on WordPress/wordpress-develop by @dennisatyoast.
5 months ago
#17
- Keywords has-patch added; needs-patch removed
This extracts the pagination into a pattern, which adds translation support to the pagination-previous and pagination-next labels.
Trac ticket: https://core.trac.wordpress.org/ticket/60298
# Testing Instructions
On your WordPress installation, make sure that you have enough posts to enable pagination on archives.
Download and install Twenty Twenty-Three.
[!Note]
At the time of writing, this only seems to work with the current Gutenberg plugin active.
[!Note]
The labels currently aren't translated in thetwentytwentythree
domain. I removed the domain in theesc_html_e
calls in the pagination pattern to utilize the translations from the root domain that have been translated for the `link_template.php` file.
View the front of the site, confirm that the pagination blocks are visible on your homepage, an archive page, and the search page. Navigate to the next page. Verify you're on the right url. Verify the labels are showing correct and the previous and next navigation points again to the right pages.
Go to settings > general and change your site language.
Once more, view the front of the site and confirm that the pagination blocks are visible on your homepage, an archive page, and the search page. The labels should be translated. Navigate to the next page. Verify you're on the right url. Verify the labels are showing correct and are translated, and the previous and next navigation points again to the right pages.
#18
in reply to:
↑ 4
@
5 months ago
I created a PR to support translation of the pagination-next and pagination-previous labels. I basically went with the first suggestion made by poena. Within Gutenberg the support for ancestor
was added in https://github.com/WordPress/gutenberg/pull/58602. This PR now introduces a pattern for the pagination that is being re-used in all three mentioned files (archive.html
, home.html
, search.html
).
I left the single heading for now. I did not see any more opinions whether this is really the best practice. But it seems unlikely to me that someone using the theme will not replace that sentence with their own copy.
#19
@
5 months ago
I have tested PR #6403
for the translations of the query pagination link texts in Twenty Twenty-Three.
Thank you for the PR.
I was about to post a longer reply saying that this PR does indeed work with Gutenberg 18x active,
and suggest that we hide the new pattern from the block inserter.
But after some thinking it dawned on me that because the fix to the query pagination block would only be available from WordPress 6.6, this would still be breaking on older versions of WordPress.
I did not consider the backwards compatibility when I added my previous comments because I was so focused on trying to solve the underlying issue, and I apologize.
I think our remaining options are to:
- Remove the strings from the markup and accept that this will be a change on live sites.
- Create new patterns with the whole query loop including the query pagination.
Unfortunately, in this theme, the query is different on the index, archive, home, blog-alternative and search, so there would need to be multiple new patterns.
@dennisatyoast commented on PR #6403:
5 months ago
#21
Following some thorough feedback by @carolinan, it makes most sense to close this PR. This change would be a BC break (only functioning from WordPress 6.6) and by closing this, anyone can start fresh on a backwards compatible change.
#22
follow-up:
↓ 23
@
4 months ago
I tried using the "Localize Text" option in the Create Block Theme plugin, on Twenty Twenty-Three, and it did not manage to add new patterns with translatable strings for the query pagination blocks.
CC @onemaggie
#23
in reply to:
↑ 22
@
4 months ago
Replying to poena:
I tried using the "Localize Text" option in the Create Block Theme plugin, on Twenty Twenty-Three, and it did not manage to add new patterns with translatable strings for the query pagination blocks.
CC @onemaggie
I think @mikachan is more familiarized with CBT these days
#24
@
4 months ago
I tried using the "Localize Text" option in the Create Block Theme plugin, on Twenty Twenty-Three, and it did not manage to add new patterns with translatable strings for the query pagination blocks.
Thanks for reporting, @poena. Could you please open a new issue upstream in the Create Block Theme repo for this? I don't believe the plugin currently handles text from the query pagination block, which is why it's not including this translation.
#25
@
4 months ago
@poena just checking on the next steps for this that I can see and I am happy to action:
- Close this ticket.
- Open a new issue in Create Block Theme.
#26
@
3 months ago
@karmatosed No, the plugin is just a tool I tried to use as a shortcut.
It doesn't update the text strings directly to the theme files on the repository; the person who uses the plugin would still need to submit the update as a patch.
This ticket was mentioned in Slack in #core-themes by karmatosed. View the logs.
3 months ago
This ticket was mentioned in PR #6663 on WordPress/wordpress-develop by @poena.
3 months ago
#28
Trac ticket: https://core.trac.wordpress.org/ticket/60298
Remove text strings that are not translatable without adding them to patterns.
This means that the texts use the default translation for the block from WordPress, not the theme.
With this PR, the archive, search and home now match the text in the query pagination in the index template.
#30
@
3 months ago
@poena
Mindblown: a blog about philosophy:
string in home.html line 6 is still not translatable.
#31
@
3 months ago
@shailu25 Yes that is correct, the PR is only one suggestion for the query pagination.
This ticket was mentioned in Slack in #core by oglekler. View the logs.
3 months ago
This ticket was mentioned in Slack in #core by oglekler. View the logs.
3 months ago
@audrasjb commented on PR #6663:
3 months ago
#35
committed in https://core.trac.wordpress.org/changeset/58459
#36
@
3 months ago
- Keywords dev-feedback needs-testing removed
Should we reopen the ticket to address the home sentence or do we prefer to address this separately?
#38
@
6 weeks ago
- Keywords needs-patch added; has-patch removed
I am going to add the keyword needs-patch as this does I think based on the last comment.
#40
@
6 weeks ago
- Keywords needs-patch removed
Hello,
Currently, this ticket is technically open in a closed milestone.
It would be best to keep it closed as fixed and open another ticket for further changes (with a reference to this one), so it can stay in the 6.6 milestone, for better visibility on what's been done on each milestone.
#42
@
2 weeks ago
- Milestone changed from 6.7 to 6.6
- Resolution set to fixed
- Status changed from reopened to closed
For now closing as advised above by @audrasjb
It would be best to keep it closed as fixed and open another ticket for further changes (with a reference to this one), so it can stay in the 6.6 milestone, for better visibility on what's been done on each milestone.
"Posts" in Twenty Twenty-Four was reported in issue 711.