summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/smart-cats-camp.md5
-rw-r--r--packages/astro/src/i18n/index.ts12
-rw-r--r--packages/astro/test/units/i18n/astro_i18n.test.js8
3 files changed, 15 insertions, 10 deletions
diff --git a/.changeset/smart-cats-camp.md b/.changeset/smart-cats-camp.md
new file mode 100644
index 000000000..96f290362
--- /dev/null
+++ b/.changeset/smart-cats-camp.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix routing prefixes when `prefixDefaultLocale` is `true`
diff --git a/packages/astro/src/i18n/index.ts b/packages/astro/src/i18n/index.ts
index 1370087bc..947689d51 100644
--- a/packages/astro/src/i18n/index.ts
+++ b/packages/astro/src/i18n/index.ts
@@ -10,7 +10,7 @@ type GetLocaleRelativeUrl = GetLocaleOptions & {
locales: Locales;
trailingSlash: AstroConfig['trailingSlash'];
format: AstroConfig['build']['format'];
- routingStrategy?: 'prefix-always' | 'prefix-other-locales';
+ routing?: 'prefix-always' | 'prefix-other-locales';
defaultLocale: string;
};
@@ -45,7 +45,7 @@ export function getLocaleRelativeUrl({
path,
prependWith,
normalizeLocale = true,
- routingStrategy = 'prefix-other-locales',
+ routing = 'prefix-other-locales',
defaultLocale,
}: GetLocaleRelativeUrl) {
const codeToUse = peekCodePathToUse(_locales, locale);
@@ -57,7 +57,7 @@ export function getLocaleRelativeUrl({
}
const pathsToJoin = [base, prependWith];
const normalizedLocale = normalizeLocale ? normalizeTheLocale(codeToUse) : codeToUse;
- if (routingStrategy === 'prefix-always') {
+ if (routing === 'prefix-always') {
pathsToJoin.push(normalizedLocale);
} else if (locale !== defaultLocale) {
pathsToJoin.push(normalizedLocale);
@@ -88,7 +88,7 @@ type GetLocalesBaseUrl = GetLocaleOptions & {
locales: Locales;
trailingSlash: AstroConfig['trailingSlash'];
format: AstroConfig['build']['format'];
- routingStrategy?: 'prefix-always' | 'prefix-other-locales';
+ routing?: 'prefix-always' | 'prefix-other-locales';
defaultLocale: string;
};
@@ -100,7 +100,7 @@ export function getLocaleRelativeUrlList({
path,
prependWith,
normalizeLocale = false,
- routingStrategy = 'prefix-other-locales',
+ routing = 'prefix-other-locales',
defaultLocale,
}: GetLocalesBaseUrl) {
const locales = toPaths(_locales);
@@ -108,7 +108,7 @@ export function getLocaleRelativeUrlList({
const pathsToJoin = [base, prependWith];
const normalizedLocale = normalizeLocale ? normalizeTheLocale(locale) : locale;
- if (routingStrategy === 'prefix-always') {
+ if (routing === 'prefix-always') {
pathsToJoin.push(normalizedLocale);
} else if (locale !== defaultLocale) {
pathsToJoin.push(normalizedLocale);
diff --git a/packages/astro/test/units/i18n/astro_i18n.test.js b/packages/astro/test/units/i18n/astro_i18n.test.js
index 126883d54..ad5a2fa23 100644
--- a/packages/astro/test/units/i18n/astro_i18n.test.js
+++ b/packages/astro/test/units/i18n/astro_i18n.test.js
@@ -286,7 +286,7 @@ describe('getLocaleRelativeUrl', () => {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es', 'en_US', 'en_AU'],
- routingStrategy: 'prefix-always',
+ routing: 'prefix-always',
},
},
};
@@ -530,7 +530,7 @@ describe('getLocaleRelativeUrlList', () => {
i18n: {
defaultLocale: 'en',
locales: ['en', 'en_US', 'es'],
- routingStrategy: 'prefix-always',
+ routing: 'prefix-always',
},
},
};
@@ -840,7 +840,7 @@ describe('getLocaleAbsoluteUrl', () => {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es', 'en_US', 'en_AU'],
- routingStrategy: 'prefix-always',
+ routing: 'prefix-always',
},
},
};
@@ -1122,7 +1122,7 @@ describe('getLocaleAbsoluteUrlList', () => {
i18n: {
defaultLocale: 'en',
locales: ['en', 'en_US', 'es'],
- routingStrategy: 'prefix-always',
+ routing: 'prefix-always',
},
},
};