Skip to content
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

Component based localization #2191

Open
Darkmift opened this issue May 16, 2024 · 4 comments
Open

Component based localization #2191

Darkmift opened this issue May 16, 2024 · 4 comments

Comments

@Darkmift
Copy link

In Vue the I18n api allows component based messages
https://kazupon.github.io/vue-i18n/guide/component.html#translation-in-functional-component

I tried looking for equivalent behaviour in I18next but could not find any so came up with this.
I am sure this could be improved upon and would appreciate some input.

https://github.com/Darkmift/ELEVATION-ITWORKS/blob/feat-i19n-tailwind/classes/react/int-tw/src/hooks/useScopedTranslation.ts

@jamuhl
Copy link
Member

jamuhl commented May 16, 2024

i18next has the concept of namespaces -> https://www.i18next.com/principles/namespaces

you can use key prefix as additional layer: https://www.i18next.com/overview/api#getfixedt

not sure what functionality you miss - having translations beside the component in file system?

@adrai
Copy link
Member

adrai commented May 16, 2024

@Darkmift
Copy link
Author

i18next has the concept of namespaces -> https://www.i18next.com/principles/namespaces

you can use key prefix as additional layer: https://www.i18next.com/overview/api#getfixedt

not sure what functionality you miss - having translations beside the component in file system?

this is what I am trying to achieve
(that example works with the hook I made)
https://github.com/Darkmift/ELEVATION-ITWORKS/blob/feat-i19n-tailwind/classes/react/int-tw/src/App.tsx

@jamuhl
Copy link
Member

jamuhl commented May 16, 2024

so my guess...find the backend that suits you best https://www.i18next.com/overview/plugins-and-utils#backends and just use useTranslation which takes care of loading the right translations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants