Skip to content

Best way to not have to duplicate a namespace? #736

Answered by aralroca
thedaviddias asked this question in Q&A
Discussion options

You must be logged in to vote

Maybe you can solve it with the loadLocaleFrom on the configuration to return the content of the namespace.

i18n.json

module.exports = {
   // ...rest of config
  "loadLocaleFrom": (lang, ns) =>
    import(`./locales/${lang}/${ns}.json`)
      // Return the inner namespace
      .then((m) => m.default[ns]),
}

Then you can use:

const { t } = useTranslation('login')
t('meta.title')

or

const { t } = useTranslation()
t('login:meta.title')

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by thedaviddias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants