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

Locales and Translations from server side #3302

Open
sergefy13 opened this issue Jan 10, 2025 · 1 comment
Open

Locales and Translations from server side #3302

sergefy13 opened this issue Jan 10, 2025 · 1 comment

Comments

@sergefy13
Copy link

Hey. Can I somehow fetch locales (languages) and translations from server (I use nuxthub with cloudflare pages) without defining them in nuxt3 app? Like I want to manage everything in backend and just use locales and translations from it as common i18n usage. What should I use for that?

Thank you for your feedback.

@jacobtshirt
Copy link

You can use the defineI18nLocale macro in a .ts/.js file that your i18n config points at.

export default defineI18nLocale(locale => {
  // for example, fetch locale messages from nuxt server
  return $fetch(`/api/${locale}`)
})

Docs can be found here

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

2 participants