sortAndFilterLocales() — astro Function Reference
Architecture documentation for the sortAndFilterLocales() function in utils.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD b7a4b27b_a1e0_4ff4_db13_350baa64114e["sortAndFilterLocales()"] 7b0bb4ed_570d_ff47_83a8_9e0495974e66["utils.ts"] b7a4b27b_a1e0_4ff4_db13_350baa64114e -->|defined in| 7b0bb4ed_570d_ff47_83a8_9e0495974e66 00c5b8fa_8c67_f870_01bf_f0ab44993c3a["computePreferredLocale()"] 00c5b8fa_8c67_f870_01bf_f0ab44993c3a -->|calls| b7a4b27b_a1e0_4ff4_db13_350baa64114e 86433feb_fb59_c31d_d344_6ab7e82d0967["computePreferredLocaleList()"] 86433feb_fb59_c31d_d344_6ab7e82d0967 -->|calls| b7a4b27b_a1e0_4ff4_db13_350baa64114e style b7a4b27b_a1e0_4ff4_db13_350baa64114e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/i18n/utils.ts lines 63–78
function sortAndFilterLocales(browserLocaleList: BrowserLocale[], locales: Locales) {
const normalizedLocales = getAllCodes(locales).map(normalizeTheLocale);
return browserLocaleList
.filter((browserLocale) => {
if (browserLocale.locale !== '*') {
return normalizedLocales.includes(normalizeTheLocale(browserLocale.locale));
}
return true;
})
.sort((a, b) => {
if (a.qualityValue && b.qualityValue) {
return Math.sign(b.qualityValue - a.qualityValue);
}
return 0;
});
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does sortAndFilterLocales() do?
sortAndFilterLocales() is a function in the astro codebase, defined in packages/astro/src/i18n/utils.ts.
Where is sortAndFilterLocales() defined?
sortAndFilterLocales() is defined in packages/astro/src/i18n/utils.ts at line 63.
What calls sortAndFilterLocales()?
sortAndFilterLocales() is called by 2 function(s): computePreferredLocale, computePreferredLocaleList.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free