Home / Function/ pathHasLocale() — astro Function Reference

pathHasLocale() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  305c67de_c541_704f_20e8_2d1dc4e1cb92["pathHasLocale()"]
  e4a1ef92_c598_36b5_dc33_9ab2535360bc["index.ts"]
  305c67de_c541_704f_20e8_2d1dc4e1cb92 -->|defined in| e4a1ef92_c598_36b5_dc33_9ab2535360bc
  66b95935_11c6_9023_fb7d_6a36ecf61752["requestHasLocale()"]
  66b95935_11c6_9023_fb7d_6a36ecf61752 -->|calls| 305c67de_c541_704f_20e8_2d1dc4e1cb92
  0c0f77e5_4d7b_ea48_7942_b6cc7bdf6896["notFound()"]
  0c0f77e5_4d7b_ea48_7942_b6cc7bdf6896 -->|calls| 305c67de_c541_704f_20e8_2d1dc4e1cb92
  09af4e13_4104_31a6_02c9_6db01b483e74["normalizeTheLocale()"]
  305c67de_c541_704f_20e8_2d1dc4e1cb92 -->|calls| 09af4e13_4104_31a6_02c9_6db01b483e74
  style 305c67de_c541_704f_20e8_2d1dc4e1cb92 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/i18n/index.ts lines 19–38

export function pathHasLocale(path: string, locales: Locales): boolean {
	// pages that use a locale param ([locale].astro or [locale]/index.astro)
	// and getStaticPaths make [locale].html the pathname during SSG
	// which will not match a configured locale without removing .html
	// as we do in normalizeThePath
	const segments = path.split('/').map(normalizeThePath);
	for (const segment of segments) {
		for (const locale of locales) {
			if (typeof locale === 'string') {
				if (normalizeTheLocale(segment) === normalizeTheLocale(locale)) {
					return true;
				}
			} else if (segment === locale.path) {
				return true;
			}
		}
	}

	return false;
}

Domain

Subdomains

Frequently Asked Questions

What does pathHasLocale() do?
pathHasLocale() is a function in the astro codebase, defined in packages/astro/src/i18n/index.ts.
Where is pathHasLocale() defined?
pathHasLocale() is defined in packages/astro/src/i18n/index.ts at line 19.
What does pathHasLocale() call?
pathHasLocale() calls 1 function(s): normalizeTheLocale.
What calls pathHasLocale()?
pathHasLocale() is called by 2 function(s): notFound, requestHasLocale.

Analyze Your Own Codebase

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

Try Supermodel Free