I use _x() now! I accepted the answer just because he understood right and was first. So don’t get confused!
$like_me_on = __('Like me on %s', 'my-plugin');
$like_us_on = __('Like us on %s', 'my-plugin');
$follow_me_on = __('Follow me on %s', 'my-plugin');
$follow_us_on = __('Follow us on %s', 'my-plugin');
$my_x_profile = __('My %s profile', 'my-plugin');
$our_x_profile = __('Our %s profile', 'my-plugin');
I have this code and i read about _n() and saw only examples with $count on wordpress codex.
The text is for a bunch of social services that will later be %s, if i would use _n then i would have this variables combined, but the translation string would be more complicated to read. So what is best practice and is this intended for pronouns or just for numbers?
It’s interesting idea and I think that such approach will work for you. What I would recommend you is that it will be better to use constructions like this:
In this case it will be easier to understand how to translate the phrase.
Also read this question How-to: Translate plural forms for themes/plugins with PoEdit to understand how to configure your
poedit
to support plural forms with WordPress keywords (like_n
,_n_noop
,_nx
and_nx_noop
).No, you should not. Use
_n()
when the placeholder can contain different numbers._n()
is not for cases where the amount is hard coded in the string.What you should use is a context parameter: