[wp-trac] [WordPress Trac] #44340: Use sprintf() to remove <strong> tags from translating strings
WordPress Trac
noreply at wordpress.org
Tue Jun 7 21:27:14 UTC 2022
#44340: Use sprintf() to remove <strong> tags from translating strings
-------------------------+-------------------------------
Reporter: saimonh | Owner: (none)
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: I18N | Version: 4.9.6
Severity: normal | Resolution: wontfix
Keywords: | Focuses: coding-standards
-------------------------+-------------------------------
Changes (by SergeyBiryukov):
* keywords: close =>
* status: new => closed
* resolution: => wontfix
* milestone: Awaiting Review =>
Comment:
Hi there, thanks for the ticket!
As noted in comment:2, it is normal for strings to have some basic HTML in
them. Splitting strings into smaller chunks often leads to losing
important context and making them less translatable without an obvious
benefit. Complete sentences, on the other hand, are much easier to
translate.
Looking at the patch, the current code:
{{{
sprintf(
/* translators: %s: User name. */
__( '<strong>ERROR</strong>: The password you entered for the
username %s is incorrect.' ),
'<strong>' . $username . '</strong>'
)
}}}
is significantly more i18n-friendly than the proposed alternative:
{{{
sprintf(
'<strong>%s</strong>: %s <strong>%s</strong> %s',
__( 'ERROR' ),
__( 'The password you entered for the username' ),
username,
__( 'is incorrect.' )
)
}}}
Note that in the former example, the second `<strong>` tag is already
moved out of the translatable string, as part of the previous efforts on
[https://core.trac.wordpress.org/query?status=closed&component=I18N&summary=~Avoid+using+HTML
removing unnecessary HTML from strings]. This is a balance between
allowing some basic HTML to preserve complete sentences and moving any
extra HTML out of translations.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44340#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list