The Node.js® Website
at main 1.0 kB view raw
1'use strict'; 2 3import localeConfig from './i18n/config.json' assert { type: 'json' }; 4 5// As set of available and enabled locales for the website 6// This is used for allowing us to redirect the user to any 7// of the available locales that we have enabled on the website 8const availableLocales = localeConfig.filter(locale => locale.enabled); 9 10// This gives an easy way of accessing all available locale codes 11const availableLocaleCodes = availableLocales.map(locale => locale.code); 12 13// This provides the default locale information for the Next.js Application 14// This is marked by the unique `locale.default` property on the `en` locale 15/** @type {import('./types').LocaleConfig} */ 16const defaultLocale = availableLocales.find(locale => locale.default); 17 18// Creates a Map of available locales for easy access 19const availableLocalesMap = Object.fromEntries( 20 localeConfig.map(locale => [locale.code, locale]) 21); 22 23export { 24 availableLocales, 25 availableLocaleCodes, 26 availableLocalesMap, 27 defaultLocale, 28};