You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I'd like to use next-international outside of the Next.js context, specifically when sending emails with react-email. For this my plan was to provide it with the translated texts but it seems there's no way to use await getI18n() and provide it with the locale I want. I tried working around that with createT but it didn't seem that intuitive after playing around a bit with it especially if I want to have working types.
Additionally, I want server actions to use the locale I hardcode for the website (this may change from values in the CMS) so that the email title and other metadata are in the correct language as well. getI18n() defaults to the user's locale which could be different from the site admin's preferred language.
Describe the solution you'd like
A clear and concise description of what you want to happen.
getI18n() could take an optional locale parameter or a new getLocaleI18n() function could be added.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
I was able to wrap react-email components with I18nClientProvider, but I'm not sure that's really the intended purpose and I haven't been able to test if this works properly when sending the emails.
Additional context
Add any other context or screenshots about the feature request here.
Sample server action:
constpayload=awaitgetPayload();const{ adminLanguage, contactEmailsTo }=awaitgetSettings();constt=awaitgetI18n();// I want to pass adminLanguage hereawaitpayload.sendEmail({to: contactEmailsTo,subject: t("email.contactSubject",{name: formData.get("name")}),email: awaitrender(<EmailTranslationsWrapperlocale="de"><ContactEmailname={formData.get("name")}email={formData.get("email")}subject={formData.get("subject")}message={formData.get("message")}/></EmailTranslationsWrapper>,),});
The text was updated successfully, but these errors were encountered:
I also have the same need, I want to use translations in API route handlers to return error messages or send emails in a specific language.
I didn't find a way to do it 😕
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I'd like to use
next-international
outside of the Next.js context, specifically when sending emails withreact-email
. For this my plan was to provide it with the translated texts but it seems there's no way to useawait getI18n()
and provide it with the locale I want. I tried working around that withcreateT
but it didn't seem that intuitive after playing around a bit with it especially if I want to have working types.Additionally, I want server actions to use the locale I hardcode for the website (this may change from values in the CMS) so that the email title and other metadata are in the correct language as well.
getI18n()
defaults to the user's locale which could be different from the site admin's preferred language.Describe the solution you'd like
A clear and concise description of what you want to happen.
getI18n()
could take an optionallocale
parameter or a newgetLocaleI18n()
function could be added.Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
I was able to wrap
react-email
components withI18nClientProvider
, but I'm not sure that's really the intended purpose and I haven't been able to test if this works properly when sending the emails.Additional context
Add any other context or screenshots about the feature request here.
Sample server action:
The text was updated successfully, but these errors were encountered: