getLocaleRelativeUrl() — astro Function Reference
Architecture documentation for the getLocaleRelativeUrl() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 5ea57fa1_9639_1ac7_9ffa_757ade8153be["getLocaleRelativeUrl()"] e4a1ef92_c598_36b5_dc33_9ab2535360bc["index.ts"] 5ea57fa1_9639_1ac7_9ffa_757ade8153be -->|defined in| e4a1ef92_c598_36b5_dc33_9ab2535360bc cf355024_249a_7bed_bfe7_1053cdb82b44["getLocaleAbsoluteUrl()"] cf355024_249a_7bed_bfe7_1053cdb82b44 -->|calls| 5ea57fa1_9639_1ac7_9ffa_757ade8153be 5297b9d5_eec4_624d_fc34_885fea95e9ff["getLocaleRelativeUrlList()"] 5297b9d5_eec4_624d_fc34_885fea95e9ff -->|calls| 5ea57fa1_9639_1ac7_9ffa_757ade8153be 89a28493_939c_c420_4d10_e20fdbd81744["peekCodePathToUse()"] 5ea57fa1_9639_1ac7_9ffa_757ade8153be -->|calls| 89a28493_939c_c420_4d10_e20fdbd81744 09af4e13_4104_31a6_02c9_6db01b483e74["normalizeTheLocale()"] 5ea57fa1_9639_1ac7_9ffa_757ade8153be -->|calls| 09af4e13_4104_31a6_02c9_6db01b483e74 style 5ea57fa1_9639_1ac7_9ffa_757ade8153be fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/i18n/index.ts lines 72–116
export function getLocaleRelativeUrl({
locale,
base,
locales: _locales,
trailingSlash,
format,
path,
prependWith,
normalizeLocale = true,
strategy = 'pathname-prefix-other-locales',
defaultLocale,
}: GetLocaleRelativeUrl) {
const codeToUse = peekCodePathToUse(_locales, locale);
if (!codeToUse) {
throw new AstroError({
...MissingLocale,
message: MissingLocale.message(locale),
});
}
const pathsToJoin = [base, prependWith];
const normalizedLocale = normalizeLocale ? normalizeTheLocale(codeToUse) : codeToUse;
if (
strategy === 'pathname-prefix-always' ||
strategy === 'pathname-prefix-always-no-redirect' ||
strategy === 'domains-prefix-always' ||
strategy === 'domains-prefix-always-no-redirect'
) {
pathsToJoin.push(normalizedLocale);
} else if (locale !== defaultLocale) {
pathsToJoin.push(normalizedLocale);
}
pathsToJoin.push(path);
let relativePath: string;
if (shouldAppendForwardSlash(trailingSlash, format)) {
relativePath = appendForwardSlash(joinPaths(...pathsToJoin));
} else {
relativePath = joinPaths(...pathsToJoin);
}
if (relativePath === '') {
return '/';
}
return relativePath;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does getLocaleRelativeUrl() do?
getLocaleRelativeUrl() is a function in the astro codebase, defined in packages/astro/src/i18n/index.ts.
Where is getLocaleRelativeUrl() defined?
getLocaleRelativeUrl() is defined in packages/astro/src/i18n/index.ts at line 72.
What does getLocaleRelativeUrl() call?
getLocaleRelativeUrl() calls 2 function(s): normalizeTheLocale, peekCodePathToUse.
What calls getLocaleRelativeUrl()?
getLocaleRelativeUrl() is called by 2 function(s): getLocaleAbsoluteUrl, getLocaleRelativeUrlList.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free