Skip to content

add translatePlural support with compiled plural functions#6

Open
kkaefer wants to merge 6 commits intotj:masterfrom
kkaefer:master
Open

add translatePlural support with compiled plural functions#6
kkaefer wants to merge 6 commits intotj:masterfrom
kkaefer:master

Conversation

@kkaefer
Copy link
Copy Markdown

@kkaefer kkaefer commented Oct 31, 2010

Syntax: "This post has #{comments:1 comment|@ comments}"

@kkaefer
Copy link
Copy Markdown
Author

kkaefer commented Oct 31, 2010

This allows for varying amounts of plural versions for different languages and uses a similar format as GNU gettext. I.e. there's a plural formula that determines the index of the plural form chosen, based on the number.

@tj
Copy link
Copy Markdown
Owner

tj commented Nov 1, 2010

ah :) good call. perhaps we should try and work it in to the regular translate() call, and just check for the new syntax with numeric values

@kkaefer
Copy link
Copy Markdown
Author

kkaefer commented Nov 1, 2010

Yeah, I'm not set on the syntax, I've tried various ways and eventually just submitted this. I also plan to integrate lingo with jade so that you can compile language-specific templates and have templates automatically translated. This would be facilitated if jade and lingo would use the same syntax for string interpolation (jade uses #{var}, while lingo uses {var}).

@tj
Copy link
Copy Markdown
Owner

tj commented Nov 1, 2010

yeah that would be sweet, I will try and toy around with this later. I think we should do it just through translate() but the syntax is fine IMO. maybe flip it so plural is first

@kkaefer
Copy link
Copy Markdown
Author

kkaefer commented Nov 1, 2010

I used the order singular-plural because that seems to be the standard (e.g. gettext, Rails' i18n use that order). I'll write and rewrite some of the translation related code later today.

…erpolation functions for regular (non-plural) strings, while short-circuiting strings without parameters for interpolation.
@kkaefer
Copy link
Copy Markdown
Author

kkaefer commented Nov 1, 2010

Now uses the absence of the params object to determine whether compilation into a interpolation function is necessary. If so, it automatically finds plurals and creates a special pluralization function for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants