How to manage 'remote' localization
Hello,
In my nuxt 3 app I get content in specified locale (using header) from CMS. So almost every component needs that data. What's the best way to manage it?
Fetch that data on server and store in pinia?
Or nuxt has an built in api to get cached data and I can use it?
Can i18n module helps in my scenario?
4 Replies
Hello again,
Yes, i18n is exactly what you need. It lets you manage the language data to be displayed to the user.
Here's the scenario: a user whose default language is English (EN) uses your application. The application must be able to retrieve data for EN only (retrieving data for all locales will hurt the application performance). Then, if the same user decides to change language, the application will retrieve the corresponding data.
@Anjjar but usually locale data stored in json files and then utilize by i18n module, how it will be in my case?
How does your CMS handle local data?
hey, take a look at in-component translations
https://i18n.nuxtjs.org/docs/guide/per-component-translations