-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plurals with "discardOldKeys" true / general plural syntax #167
Comments
I've also struggled with handling extraction with pluralization. t('TestKey_interval', { count: count, defaultValue: '(1){test};(2-inf)}{tests};' }) that way you could extract the pluralization, But I don't know if that's the best way |
Interesting. I have not seen that syntax with the semicolons inside the default value string to separate the defaults. I'll take a look at the postprocessor and see how that works. thanks for this! |
You can also consider using ICU format <Plural
i18nKey="TestKey"
count={count}
one="test"
other="tests"
/> |
This would be very useful. Any chances for making it work? |
Is this issue actually related to Also, I'm not sure which default value you would expect to be used. I feel like having a comment hint for that purpose would be slightly "too much" and using the singular default value as default value for plurals doesn't seem correct either (because it will be considered as translated when it should be reworked). Especially with intervalplural-preprocessor, I'm not sure how all this should work together. I'm under the impression that this is rather an issue for the translation tool: it should display singular and plurals "together", so that they can be translated in a batch. But I definitely don't have a strong opinion. |
@gilbsgilbs function totalItems(count: number) {
return t('total_count', {
count,
defaultValue_one: 'Total {{count}} item',
defaultValue_other: 'Total {{count}} items',
});
} and then: console.log(totalItems(0)); // Total 0 items
console.log(totalItems(1)); // Total 1 item
console.log(totalItems(4)); // Total 4 items
console.log(totalItems(127)); // Total 127 items Same for other suffixes used in different languages like |
I didn't know that. This is a nice feature request. I'll happily accept PRs for it. |
Describe the bug
There seems to be no way to have the extraction accept a default value for the plural of a word.
How to reproduce
Trying to see how pluralization works with the extraction and also providing a defaultValue.
Based on the i18next docs, passing in "{count: x}" to the options object will let i18next look for the "key**_plural**" key, yes?
so given this code:
the extracted string looks like this:
How am I supposed to pass in what the default plural is?
I tried this to see what would happen:
But the extracted strings just overwrote the initial one and the extracted strings end up like this:
If I had the "TestKey" and "TestKey_plural" already in the file, then the code should work. But this plugin is for extracting/generating those keys/values in the file for me automatically. I'm just trying to figure out what the syntax is for what I'm describing.
What am I missing?
Babel configuration:
Expected behavior
Have the extraction generate the key and key_plural entries with proper default values.
What actually happens
Your environment
The text was updated successfully, but these errors were encountered: