WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#32817 closed defect (bug) (fixed)

Avoid HTML tags in translation strings (WP_Customize_Themes_Section)

Reported by: henrikakselsen Owned by: SergeyBiryukov
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.3
Component: Customize Keywords: has-patch needs-refresh
Focuses: Cc:
PR Number:

Description

I have setup the translation to only evaluate the text, not the html tags.

Attachments (3)

32817.patch (1.7 KB) - added by henrikakselsen 4 years ago.
Only translate text portion of strings
32817.2.patch (1.7 KB) - added by henrikakselsen 4 years ago.
Fix echo command for best practices
32817.rtl.png (13.3 KB) - added by SergeyBiryukov 4 years ago.

Download all attachments as: .zip

Change History (11)

@henrikakselsen
4 years ago

Only translate text portion of strings

#1 @GaryJ
4 years ago

Hi @henrikakselsen, thanks for submitting your first report and patch!

A couple of points:

  • The first pair of echo have got a pair of () around the content - these are not needed and should be removed.
  • Instead of using . to echo, you can use ,, which has a slight performance benefit, as it echos the values straight away, instead of building up into a single string first.

If you do a new patch, just upload it as the same name (leave the existing one there for historical reference), and Trac will append a suffix so that it becomes a new file name.

@henrikakselsen
4 years ago

Fix echo command for best practices

#2 @henrikakselsen
4 years ago

Thank you Gary. I rerolled the patch now.

#3 @celloexpressions
4 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.3

I've never seen , as opposed to . used in core, but I'm not personally opposed. This looks like it should be fine for 4.3 if it gets committed in a reasonably timely manner. Only possible issue would be if you wanted to move the theme placeholder, but not sure that that would be needed (this isn't my area of expertise).

#4 follow-up: @obenland
4 years ago

  • Milestone 4.3 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

We need the placeholder for RTL languages to be able to shift that value around.
Generally it should be avoided to use HTML in translation strings, but things like a single anchor or scenarios like this are exceptions to that rule.

#5 in reply to: ↑ 4 @SergeyBiryukov
4 years ago

  • Milestone set to 4.3
  • Resolution wontfix deleted
  • Status changed from closed to reopened

Replying to obenland:

We need the placeholder for RTL languages to be able to shift that value around.

.customize-action is a block element, so there's no need to move the placeholder here: 32817.rtl.png.

Generally, I don't think RTL languages have to shift placeholders often, text direction should take care of that.

Replying to GaryJ:

Instead of using . to echo, you can use ,, which has a slight performance benefit, as it echos the values straight away, instead of building up into a single string first.

I'd suggest leaving this discussion for #31950 and using concatenation for now for consistency with other core files.

#6 follow-up: @ocean90
4 years ago

  • Keywords needs-refresh added

I agree that it's safe to remove the placeholder here. We should do the same in WP_Customize_Themes_Section::render().

#7 in reply to: ↑ 6 @SergeyBiryukov
4 years ago

Replying to ocean90:

We should do the same in WP_Customize_Themes_Section::render().

The patch is for WP_Customize_Themes_Section::render(). Did you mean any other class?

#8 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from reopened to closed

In 33078:

Customizer: Remove HTML tags from two translatable strings.

props henrikakselsen.
fixes #32817.

Note: See TracTickets for help on using tickets.