Opened 3 years ago
Last modified 3 years ago
#44340 new defect (bug)
Make use of sprintf function while translating strings
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.9.6 |
Component: | Users | Keywords: | has-patch close |
Focuses: | coding-standards | Cc: |
Description
This is not a bug rather it's an improvement. In the wp-includes/user.php file, there are some <strong> tag has which has been used inside the translated () function.
So it's better to make use of sprintf function here than hard-coding the <strong> tag.
Screenshot: https://d.pr/free/i/qbHq2z
Regards
Attachments (1)
Change History (3)
Note: See
TracTickets for help on using
tickets.
Hi @saimonh,
Congrats on creating your first ticket :-)
In this case, I'd say that the change is unnecessary.
It's fine for strings to have basic HTML in them. In some cases, it's necessary, so that the translator can choose what word has the strong emphasis, or which words are the link text, etc.
In this case, you've split the strings up into multiple strings, which doesn't help with understanding context - they might be a different word for "ERROR", depending on what the issue is, but after your patch, that wouldn't be easy to adjust for, without also adding context (
_x()
) which then results in the same string having to be translated mutliple times.Also, you've left the colon (
:
) in the sprintf template, meaning other punctuation can't be used if other locales use something different to a colon.If markup is only at the ends of a string, then that's more likely to be a good candidate for pulling the markup out.