-
Notifications
You must be signed in to change notification settings - Fork 5
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support TypeScript #4
Comments
The type definitions used by react-i18next are quite lengthy and complex, and that's not something I'd like to duplicate and maintain separately for i18next-vue. There seem to be efforts of extracting the types to the core library, see i18next/i18next#1504. |
@pedrodurek interesting... also others are looking for it 馃槈 |
It looks like the linked issue has been merged; is this something that could be re-evaluated at this point? |
I look into this in the near future and see how to integrate the types best. We'll probably not publish a new version with this right away, but wait a bit for the "dust to settle". As @adrai's linked ticket shows, there are still quite some type-related changes and fixes going on in i18next itself. |
We plan to include this in i18next-vue v3. In fact, you can try it in the alpha version already: https://github.com/i18next/i18next-vue/releases/tag/v3.0.0-alpha.0 The syntax is like in your example const { t } = useTranslation('settings'); This should work as good as the types for See #16 for other changes planned for version 3. |
As outlined above, this is implemented in v3. |
馃殌 Feature Proposal
Ref:
When I use i18next react, it supports TypeScript. Could this vue version also add TypeScript support for the $t interface?
https://react.i18next.com/latest/typescript
Motivation
Add translation key validation/auto-completion support during dev.
Example
//similar usage as react version.
const { t } = useTranslation('settings')//namespace support, load namespace if it's not loaded
t('TranslationKey')//can be validated by TypeScript
The text was updated successfully, but these errors were encountered: