Closed Marsony closed 10 months ago
This seems a bit related to #229 - we now expose the internal createT
function that is used to construct the useI18n
/ useScopedI18n
hooks. It's not documented as it's a very niche use-case, but you can check out the source code directly (it's not very complex to use): https://github.com/QuiiBz/next-international/blob/main/packages/next-international/src/common/create-use-i18n.ts
This seems a bit related to #229 - we now expose the internal
createT
function that is used to construct theuseI18n
/useScopedI18n
hooks. It's not documented as it's a very niche use-case, but you can check out the source code directly (it's not very complex to use): https://github.com/QuiiBz/next-international/blob/main/packages/next-international/src/common/create-use-i18n.ts
Can you please provide minimal repro or maybe example? Would like to understand ideas for implementation.
As I said we don't have any documentation on it since it's a niche use case, and for an example you can take a look at the code I linked above . createT
returns a useI18n
/ useScopedI18n
function based on if you pass it a scope in second argument.
I don't have access to your current app, so I can't really give you more details on how to use it :/
Closing for now, happy to re-open and help when we have more information.
Well... I could be interested too.
So far I've structured my code so that my locales files contain a label
field, and I'm about to write my "Language Switcher" component. So, I'm finally going to use these label
fields.
I could just easily make an object that contains each language flag as keys, and each associated label as values, but I'm a bit embarrassed about defining vocabulary outside the locales files.
I'll probably create an issue on the same topic. (Although, I may have a slightly more twisted idea that could work just as well to write all the values once and "Inject" them into all the other locales files afterwards).
EDIT: hmmm, nope. I opted for the twisted idea, and I don't need any manual control of the needed locale for now.
Is your feature request related to a problem? Please describe. We are faced with a situation where we cannot use the locales themselves in Next. I mean that we can't use i18n object in the next.config.js. This is due to the limit of available languages count (100), and we support a sufficient number of countries and languages and process this using routes. (/en-EN, etc, over than 160+ pairs in summary). Also your library is requires to use
defaultLocale
in i18nDescribe the solution you'd like Is it possible to get locales inside server functions? For example, right now
next-international
requires to use getServerSideProps inside getLocaleProps and we can't control the locale which we need to return because you extractlocale
from thenextjs i18n
.Describe alternatives you've considered Maybe some
getTranslations(props: { locale: string })
methodP.S. we using pages router