-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
ngettext replacement ? #1096
Comments
the save missing feature https://github.com/i18next/i18next/blob/master/src/Translator.js#L158 will already create the needed keys for both singular and plural - just it uses the same defaultValue...but i guess that is ok - as it's not the developers concern to get both singular and plural correct -> translators will/should review texts made by developers anyway. So eg. using https://locize.com you will get all that out of the box - without having to handle the saveMissings on your backend |
So is your need more related to defining defaultValues for all possible plural forms (depending on your source language)? |
We are just used to that application is fully working with default english language with any newly feature added. Also we have some applications that are not going to be translated anytime soon but may be translated in the future. Therefore singular and plural value in english (or any other language with one plural form) is enough for the application to work - in this case not any translation files are needed. If we migrate to i18next we have to create english translation file and fill it with all the plurals. Also that file has to be manually managed by programmers if they add new feature. |
ok i see...basically you would prefer the key to be the fallback (which works for i18next) but for plural cases you like to add the defaults. we fallback either to default value or key here: https://github.com/i18next/i18next/blob/master/src/Translator.js#L121 when doing a translation lookup we return found or not found value here: https://github.com/i18next/i18next/blob/master/src/Translator.js#L278 we could add the needed pluralSuffix from here: https://github.com/i18next/i18next/blob/master/src/Translator.js#L254 to that return value and than use that suffix (if exists = isAPlural) to check if there is some Would that help? |
Yeah definitely that would be great feature ;) |
If you feel comfortable you might add a PR...else i will see what i can do...not to complicated...but currently limited on time. |
I might try that today. Also in my opinion plural suffix is very 'inaccurate' feature. In many languages there are more suffixes (in my lanaguage too - Slovak), also in english (s, es). |
yes...there are more suffixes for languages having multiple pluralforms - just checkout: https://www.i18next.com/translation-function/plurals#languages-with-multiple-plurals (below there is also a tool to lookup those suffixes - plus using locize it will do this automatically for target languages - so one thing less to think about.) |
Hello,
Currently we hare using ngettext function in our PHP app. This function includes default values for both singular and plural strings.
If we use i18next in our JS app the programmer is able to specify only one version of the default string (which could be key or defaultValue property). Therefore, he has to add the plural version to the translation file manually. Using ngettext in PHP the app is fully functional without programmer touching the translation files.
I would like to ask if you plan to add some function that could be used to replace ngettext ?
Thnaks.
The text was updated successfully, but these errors were encountered: