nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

feat: runtime config support for `detectBrowserLanguage` #2824

Closed BobbieGoede closed 7 months ago

BobbieGoede commented 7 months ago

πŸ”— Linked issue

❓ Type of change

πŸ“š Description

These have been merged and released

Primary motivation for adding runtime support is to actually to merge more test files πŸ˜‚. Most if not all code for detectBrowserLanguage is used at runtime, so there is no need to rebuild the project to test each options.

https://github.com/unjs/nitro/pull/1831 allows us to override runtime configs objects with environment variables, as this is currently not possible.

This PR changes the @nuxt/test-utils code further, startServer now optionally accepts additional environment variables. And I added helper functions to make setting runtime config variables via environment variables easier.

Using the following in a test

  await setRuntimeConfig({
    public: {
      i18n: {
        detectBrowserLanguage: false
      }
    }
  })

Will be converted into NUXT_PUBLIC_I18N_DETECT_BROWSER_LANGUAGE=false and restarts the server with all properties in the passed object.

πŸ“ Checklist