Home / Function/ getLocaleByPath() — astro Function Reference

getLocaleByPath() — astro Function Reference

Architecture documentation for the getLocaleByPath() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  f14cdaf4_cd3b_c775_31a2_e861173b5741["getLocaleByPath()"]
  e4a1ef92_c598_36b5_dc33_9ab2535360bc["index.ts"]
  f14cdaf4_cd3b_c775_31a2_e861173b5741 -->|defined in| e4a1ef92_c598_36b5_dc33_9ab2535360bc
  style f14cdaf4_cd3b_c775_31a2_e861173b5741 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/i18n/index.ts lines 206–220

export function getLocaleByPath(path: string, locales: Locales): string {
	for (const locale of locales) {
		if (typeof locale !== 'string') {
			if (locale.path === path) {
				// the first code is the one that user usually wants
				const code = locale.codes.at(0);
				if (code === undefined) throw new AstroError(i18nNoLocaleFoundInPath);
				return code;
			}
		} else if (locale === path) {
			return locale;
		}
	}
	throw new AstroError(i18nNoLocaleFoundInPath);
}

Domain

Subdomains

Frequently Asked Questions

What does getLocaleByPath() do?
getLocaleByPath() is a function in the astro codebase, defined in packages/astro/src/i18n/index.ts.
Where is getLocaleByPath() defined?
getLocaleByPath() is defined in packages/astro/src/i18n/index.ts at line 206.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free