[wp-trac] [WordPress Trac] #22229: Plurals in JavaScript
WordPress Trac
noreply at wordpress.org
Mon Oct 22 12:19:34 UTC 2012
#22229: Plurals in JavaScript
-------------------------+------------------
Reporter: nacin | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.5
Component: I18N | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+------------------
Comment (by nbachiyski):
Nacin, I like the idea.
A couple of notes on the implementation:
* I would hide the big {{{if}}} in a {{{Translations}}} method like
{{{translate_entry_or_return_entry()}}}, which instead of {{{false}}}
returns the entry itself. This way you won't need the special case and the
code will be easier to follow.
* The default number of plurals and the default expression do not belong
to this part of the code. We're dealing with JS here, not with gettext
specifics. I have two ideas around this problem:
0. Make {{{nplurals_and_expression_from_header()}}} and
{{{parenthesize_plural_exression()}}} static. Then just call
{{{Gettext_Translations::nplurals_and_expression_from_header(
$mo->get_header( 'Plural-Forms' ) );}}}. Or better, create an instance
method of {{{Gettext_Translations}}} called
{{{nplurals_and_expression()}}}, which uses the header from the instance.
0. We can create a {{{NOOP_Gettext_tarnslations}}}, which extends
{{{Gettext_Translations}}} and all the functionality, except actually
translating is still there. The note about {{{nplurals_and_expression()}}}
still applies.
* I agree with scribu that we shouldn't create a new function each time. I
think we should keep the pretty syntax of {{{numItems(5)}}} (it's pretty
and I don't need to remember any other function names) and we should have
a function generator, building a single function and just varying on
singular/plural.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22229#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list