diff --git a/website/src/lib/locales.mjs b/website/src/lib/locales.mjs index 05684d8d4..14cef3c06 100644 --- a/website/src/lib/locales.mjs +++ b/website/src/lib/locales.mjs @@ -1,40 +1,47 @@ -/** - * Shared i18n locale configuration. - * - * Single source of truth for locale definitions used by: - * - website/astro.config.mjs (Starlight i18n) - * - tools/build-docs.mjs (llms-full.txt locale exclusion) - * - website/src/pages/404.astro (client-side locale redirect) - * - * The root locale (English) uses Starlight's 'root' key convention - * (no URL prefix). All other locales get a URL prefix matching their key. - */ - -export const locales = { - root: { - label: 'English', - lang: 'en', - }, - 'vi-vn': { - label: 'Tiếng Việt', - lang: 'vi-VN', - }, - 'zh-cn': { - label: '简体中文', - lang: 'zh-CN', - }, - fr: { - label: 'Français', - lang: 'fr-FR', - }, - cs: { - label: 'Čeština', - lang: 'cs-CZ', - }, -}; - -/** - * Non-root locale keys (the URL prefixes for translated content). - * @type {string[]} - */ -export const translatedLocales = Object.keys(locales).filter((k) => k !== 'root'); +/** + * Shared i18n locale configuration. + * + * Single source of truth for locale definitions used by: + * - website/astro.config.mjs (Starlight i18n) + * - tools/build-docs.mjs (llms-full.txt locale exclusion) + * - website/src/pages/404.astro (client-side locale redirect) + * + * The root locale (English) uses Starlight's 'root' key convention + * (no URL prefix). All other locales get a URL prefix matching their key. + */ + +/** + * @typedef {Object} Locale + * @property {string} label - The display name of the locale. + * @property {string} lang - The BCP 47 language tag. + */ + +/** @type {Record} */ +export const locales = { + root: { + label: 'English', + lang: 'en', + }, + 'vi-vn': { + label: 'Tiếng Việt', + lang: 'vi-VN', + }, + 'zh-cn': { + label: '简体中文', + lang: 'zh-CN', + }, + fr: { + label: 'Français', + lang: 'fr-FR', + }, + cs: { + label: 'Čeština', + lang: 'cs-CZ', + }, +}; + +/** + * Non-root locale keys (the URL prefixes for translated content). + * @type {string[]} + */ +export const translatedLocales = Object.keys(locales).filter((k) => k !== 'root');