From 40fc29e8ccbdd24e63411cc1e1e635a290413745 Mon Sep 17 00:00:00 2001 From: LEGO Technix <109212476+lego-technix@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:54:21 +0200 Subject: [PATCH] feat(pix-site): add runtimeConfig.public.availableLocaleCodes --- pix-site/i18n.config.ts | 6 +++++- pix-site/nuxt.config.ts | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pix-site/i18n.config.ts b/pix-site/i18n.config.ts index dc932016e..16bd18a0a 100644 --- a/pix-site/i18n.config.ts +++ b/pix-site/i18n.config.ts @@ -2,9 +2,11 @@ import { generateConfig } from '../shared/i18n.config'; const reachableLocales = [ { + // The "code" property should be renamed into "name": https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale code: 'en', iso: 'en', file: 'en.js', + // The "name" property should be renamed into "displayName": https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames name: 'English', icon: 'globe-europe.svg', domain: process.env.DOMAIN_ORG, @@ -43,6 +45,8 @@ const reachableLocales = [ }, ]; +const reachableLocaleNames = reachableLocales.map(reachableLocale => reachableLocale.code); + const config = generateConfig(reachableLocales); export default { ...config }; -export { reachableLocales }; +export { reachableLocales, reachableLocaleNames }; diff --git a/pix-site/nuxt.config.ts b/pix-site/nuxt.config.ts index beba74bed..c8b12cd9d 100644 --- a/pix-site/nuxt.config.ts +++ b/pix-site/nuxt.config.ts @@ -1,5 +1,5 @@ import { getRoutesToGenerate } from './services/get-routes-to-generate'; -import i18nConfig, { reachableLocales } from './i18n.config'; +import i18nConfig, { reachableLocales, reachableLocaleNames } from './i18n.config'; export default async () => { const routes = process.env.NODE_ENV !== 'test' ? await getRoutesToGenerate({ locales: i18nConfig.locales }) : []; @@ -24,6 +24,7 @@ export default async () => { siteDomain: process.env.SITE_DOMAIN, formKeysToMap: process.env.FORM_KEYS_TO_MAP || null, availableLocales: reachableLocales, + availableLocaleNames: reachableLocaleNames, }, }, nitro: {