Type-safe translations do not work with context
🐛 Bug Report
Similar to https://github.com/i18next/react-i18next/issues/1386 having a context does not work with typesafety:
To Reproduce
{
"key_optionA": "My Option A",
"key_optionB": "My Option B",
}
t('key', {context: "optionA"}); // TS error, only key_optionA or key_optionB are allowed
t('key', {context: "optionB"}); // TS error
Expected behavior
Such resources should be allowed to be used without the suffix.
Your Environment
-
i18next@^21.8.14 -
[email protected]
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Not stale
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale...
@pedrodurek is there a chance this is going to work with your new TypeScript rewrite? btw: any ETA?
@adrai @pedrodurek any chance of removing the stale tag permanently so I don't have to post a comment every week? 😄
i18next v22.4.5 might be better
I faced the same problem
i18next: 22.4.11 react-i18next: 12.2.0
https://github.com/i18next/react-i18next/issues/1617
i18next v23.0.0 will probably not address that yet
i18next v23.2.11 has still not addressed.
getting error when using context
handled in i18next v23.4.0 (https://github.com/i18next/i18next/pull/2007/files#diff-97e65d0ee521805ff4ac2d967b61062da8f5543569da4177ceeff689ce4463a3R150)