Skip to content

Added default value for count#35

Open
benjaminwinger wants to merge 1 commit into
kikito:masterfrom
benjaminwinger:count-default
Open

Added default value for count#35
benjaminwinger wants to merge 1 commit into
kikito:masterfrom
benjaminwinger:count-default

Conversation

@benjaminwinger

Copy link
Copy Markdown

If count is used in a message, but not passed as a variable, it should provide a meaningful default.

I'm not really sure why you would want to implement a plural message without a count argument, but the tests didn't really make sense:

assert.equal("Une chose.", i18n('message', {count = 0})) is clearly incorrect, as while 0 is in the same CLDR plural category as 1 in French, it doesn't mean the same thing. So without the ability to match against numerical constants in addition to CLDR plural categories, it only works to have the message be:

i18n.set('fr.message', {
    one   = "%{count} chose.",
    other = "%{count} choses."
})

But then the defaults to 1 test produces nil chose., which isn't helpful, so we need a default value for count as well as a default plural category for it.

flexiondotorg added a commit to Oval-Tutu/smiti18n that referenced this pull request Jan 12, 2025
- Create new data table for default count value
- Move count default handling to treatNode
- Update tests to verify count interpolation
- Maintain immutability of input data table

Cherry-picked from kikito/i18n.lua#35
flexiondotorg added a commit to Oval-Tutu/smiti18n that referenced this pull request Jan 12, 2025
- Create new data table for default count value
- Move count default handling to treatNode
- Update tests to verify count interpolation
- Maintain immutability of input data table

Cherry-picked from kikito/i18n.lua#35
flexiondotorg added a commit to Oval-Tutu/smiti18n that referenced this pull request Jan 12, 2025
- Create new data table for default count value
- Move count default handling to treatNode
- Update tests to verify count interpolation
- Maintain immutability of input data table

Cherry-picked from kikito/i18n.lua#35
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.

1 participant