This commit is contained in:
Dong Mengzhe 2026-06-07 01:31:08 +08:00 committed by GitHub
commit f07d54992b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 47 additions and 40 deletions

View File

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