Best way to not have to duplicate a namespace? #736
-
Hello, We have a project which has one JSON file per page:
We use a third-party to handle the translation (phrase.com) which kind of flat all the keys to be unique (we can't have 2 keys with the same name, even in different files) Which means that we have to add a namespace in each of these files: Login has:
Problem is, when we call @aralroca, do you see any possible way to keep each key unique, even they are in separated file and not have that kind of redundancy to call the "login" twice? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Maybe you can solve it with the 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') |
Beta Was this translation helpful? Give feedback.
Maybe you can solve it with the
loadLocaleFrom
on the configuration to return the content of the namespace.i18n.json
Then you can use:
or