Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added default value for count #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benjaminwinger
Copy link

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant