From b73e164482b9e5454032650f83eee81730c72926 Mon Sep 17 00:00:00 2001 From: Auto PR Bot Date: Sun, 7 Jun 2026 01:30:23 +0800 Subject: [PATCH] Improve code quality: auto-pr/type_annotations-1780767022 --- website/src/lib/locales.mjs | 87 ++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 40 deletions(-) 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');