Opened 13 years ago
Closed 13 years ago
#20188 closed defect (bug) (fixed)
_n_noop() does not accept a textdomain
Reported by: | scribu | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | I18N | Keywords: | has-patch |
Focuses: | Cc: |
Description
A plugin tryng to use register_post_status() will have a hard time making the 'label_count' property translatable, since _n_noop() doesn't have a textdomain parameter, although translate_nooped_plural() does have it.
Previously: #13996
Attachments (1)
Change History (9)
#1
@
13 years ago
- Milestone Awaiting Review deleted
- Resolution set to maybelater
- Status changed from new to closed
- Type changed from defect (bug) to enhancement
#2
@
13 years ago
- Resolution maybelater deleted
- Status changed from closed to reopened
- Type changed from enhancement to defect (bug)
This is in fact a bug.
Example: a plugin registers a post status and uses _n_noop()
for its 'label_count' parameter, and its parameters are correctly added to the plugin's POT when it's scanned. However, when the label is output by WordPress using translated_nooped_plural()
there's no textdomain parameter present, so gettext will try to translate the string according to core's textdomain rather than the plugin's.
I have a patch for this which I'll upload later when I'm back at my computer.
#4
@
13 years ago
Not sure I am following. Example usage in a plugin:
$num_apples = 12; $apple_string = _n_noop( 'Apple', 'Apples' ); translate_nooped_plural( $apple_string, $num_apples, 'my-plugin-textdomain' );
When makepot.php runs over this file, the strings 'Apple' and 'Apples' will be picked up and added to the plugin's POT.
When translate_nooped_plural() fires, it will call _n() internally with the domain passed to it.
#5
follow-up:
↓ 6
@
13 years ago
The trouble comes when translate_nooped_plural() isn't called by the plugin, but by Core. This happens with register_post_status(), as mentioned in the ticket description.
#6
in reply to:
↑ 5
@
13 years ago
- Milestone changed from Awaiting Review to 3.4
Replying to scribu:
This happens with register_post_status(), as mentioned in the ticket description.
Kind of. I would have had to look up exactly how core translates 'label_count', as that's just about all that's mentioned. That's okay, though — I get it now.
Okay, so, let's fix it.
It actually doesn't need it.
makepot does not use textdomains when scanning a file for strings. (It may in the future as an enhancement, to allow us to do things like move all multisite strings to their own pot, even if they exist in a regular core file.) The only job of _n_noop() is to get the string into the POT file. After that, translate_nooped_plural() is used to translate a string according to the textdomain.
We can consider this one an enhancement + maybelater, I think.