Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
As a developer, I want to be able to change the default currency and locale at runtime. An example might be a multistore setup where I might have a plugin loading the store configuration including default language and currency for the store (which is a pretty common scenario).
Unfortunately, the current implementation of the i18n-cookies plugin only relies on properties provided in nuxt.config.js. Therefore, influencing the outcome of this plugin at runtime is rather impossible - not good in a multistore setup where we have a single Vue Storefront application displaying several separate stores with different locale/currency settings.
This PR creates a gateway for Nuxt plugins to add defaultLocale, defaultCurrency and defaultCountry to the context object so that the i18n-cookies plugin picks these values up and does its job the usual way. An example of a flow supported by this PR could be:
Plugin A loads store configuration from Commerce API. The configuration contains default language and currency for the store. The plugin writes these values to the application context object.
Plugin b (i18n-cookies) reads these values from the context. If it does not find them, it falls back to the configuration defined in nuxt.config.js.
Description
As a developer, I want to be able to change the default currency and locale at runtime. An example might be a multistore setup where I might have a plugin loading the store configuration including default language and currency for the store (which is a pretty common scenario).
Unfortunately, the current implementation of the i18n-cookies plugin only relies on properties provided in
nuxt.config.js
. Therefore, influencing the outcome of this plugin at runtime is rather impossible - not good in a multistore setup where we have a single Vue Storefront application displaying several separate stores with different locale/currency settings.This PR creates a gateway for Nuxt plugins to add
defaultLocale
,defaultCurrency
anddefaultCountry
to thecontext
object so that thei18n-cookies
plugin picks these values up and does its job the usual way. An example of a flow supported by this PR could be:language
andcurrency
for the store. The plugin writes these values to the applicationcontext
object.context
. If it does not find them, it falls back to the configuration defined innuxt.config.js
.Related Issue
IN-1576
Types of changes
Checklist:
Changelog