Make WordPress Core

Opened 5 months ago

Last modified 6 days ago

#60298 reopened defect (bug)

Text embedded in theme template is not translatable

Reported by: wildworks's profile wildworks Owned by: audrasjb's profile audrasjb
Milestone: 6.6 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch dev-feedback needs-testing
Focuses: Cc:

Description (last modified by sabernhardt)

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

Twenty Twenty-Four

Attachments (1)

tt3.png (48.3 KB) - added by poena 3 weeks ago.
Twenty Twenty-Three query pagination with custom text strings removed

Download all attachments as: .zip

Change History (32)

#1 @sabernhardt
5 months ago

  • Component changed from Themes to Bundled Theme
  • Description modified (diff)

"Posts" in Twenty Twenty-Four was reported in issue 711.

#2 @poena
5 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":"#"} /-->
Last edited 5 months ago by poena (previous) (diff)

#3 @poena
5 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 6.5

#4 follow-up: @poena
5 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.

Last edited 5 months ago by poena (previous) (diff)

This ticket was mentioned in PR #6012 on WordPress/wordpress-develop by @poena.


5 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

#6 @poena
5 months ago

  • Keywords needs-patch added; has-patch removed

@mukesh27 commented on PR #6012:


5 months ago
#8

@carolinan The changes look good. Are you going to open PR for Twenty Twenty-Three?

@poena commented on PR #6012:


5 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 @poena
4 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 @audrasjb
4 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.

#12 @audrasjb
4 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 57588:

Twenty Twenty-Four: Add missing translation functions to text strings.

This changeset updates some text labels in footer.php to make them translatable.

Props wildworks, sabernhardt, poena, onemaggie, luminuu, mukesh27.
Fixes #60298.

#13 @audrasjb
4 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.

#15 @poena
4 months ago

  • Milestone changed from 6.5 to 6.6

This ticket was mentioned in Slack in #core-themes by karmatosed. View the logs.


2 months ago

This ticket was mentioned in PR #6403 on WordPress/wordpress-develop by @dennisatyoast.


2 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 the twentytwentythree domain. I removed the domain in the esc_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 @dennisatyoast
2 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 @poena
2 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.

#20 @karmatosed
2 months ago

  • Keywords dev-feedback added

@dennisatyoast commented on PR #6403:


8 weeks 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: @poena
7 weeks 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 @onemaggie
7 weeks 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 @mikachan
7 weeks 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 @karmatosed
3 weeks 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 @poena
3 weeks 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 weeks ago

This ticket was mentioned in PR #6663 on WordPress/wordpress-develop by @poena.


3 weeks 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.

@poena
3 weeks ago

Twenty Twenty-Three query pagination with custom text strings removed

#29 @poena
2 weeks ago

  • Keywords needs-testing added

#30 @shailu25
2 weeks ago

@poena

Mindblown: a blog about philosophy: string in home.html line 6 is still not translatable.

#31 @poena
2 weeks 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.


6 days ago

Note: See TracTickets for help on using tickets.