0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

chore: remove experimental from i18n configuration (#9264)

* update types and schema

* update typescript files

* update tests

* chore: update JSDoc
This commit is contained in:
Emanuele Stoppa 2023-12-04 08:43:57 -05:00 committed by GitHub
parent 2fdcd6d719
commit bd9907867b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 370 additions and 420 deletions

View file

@ -1414,6 +1414,124 @@ export interface AstroUserConfig {
* Astro offers experimental flags to give users early access to new features.
* These flags are not guaranteed to be stable.
*/
/**
* @docs
* @name i18n
* @type {object}
* @version 3.5.0
* @type {object}
* @description
*
* Configures experimental i18n routing and allows you to specify some customization options.
*
* See our guide for more information on [internationalization in Astro](/en/guides/internationalization/)
*/
i18n?: {
/**
* @docs
* @kind h4
* @name i18n.defaultLocale
* @type {string}
* @version 3.5.0
* @description
*
* The default locale of your website/application. This is a required field.
*
* No particular language format or syntax is enforced, but we suggest using lower-case and hyphens as needed (e.g. "es", "pt-br") for greatest compatibility.
*/
defaultLocale: string;
/**
* @docs
* @kind h4
* @name i18n.locales
* @type {Locales}
* @version 3.5.0
* @description
*
* A list of all locales supported by the website, including the `defaultLocale`. This is a required field.
*
* Languages can be listed either as individual codes (e.g. `['en', 'es', 'pt-br']`) or mapped to a shared `path` of codes (e.g. `{ path: "english", codes: ["en", "en-US"]}`). These codes will be used to determine the URL structure of your deployed site.
*
* No particular language code format or syntax is enforced, but your project folders containing your content files must match exactly the `locales` items in the list. In the case of multiple `codes` pointing to a custom URL path prefix, store your content files in a folder with the same name as the `path` configured.
*/
locales: Locales;
/**
* @docs
* @kind h4
* @name i18n.fallback
* @type {Record<string, string>}
* @version 3.5.0
* @description
*
* The fallback strategy when navigating to pages that do not exist (e.g. a translated page has not been created).
*
* Use this object to declare a fallback `locale` route for each language you support. If no fallback is specified, then unavailable pages will return a 404.
*
* ##### Example
*
* The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
*
* ```js
* export default defineConfig({
* experimental: {
* i18n: {
* defaultLocale: "en",
* locales: ["en", "fr", "pt-br", "es"],
* fallback: {
* pt: "es",
* fr: "en"
* }
* }
* }
* })
* ```
*/
fallback?: Record<string, string>;
/**
* @docs
* @kind h4
* @name i18n.routing
* @type {Routing}
* @version 3.7.0
* @description
*
* Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
*/
routing?: {
/**
* @docs
* @name i18n.routing.prefixDefaultLocale
* @type {boolean}
* @default `false`
* @version 3.7.0
* @description
*
* When `false`, only non-default languages will display a language prefix.
* The `defaultLocale` will not show a language prefix and content files do not exist in a localized folder.
* URLs will be of the form `example.com/[locale]/content/` for all non-default languages, but `example.com/content/` for the default locale.
*
* When `true`, all URLs will display a language prefix.
* URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
* Localized folders are used for every language, including the default.
*/
prefixDefaultLocale: boolean;
/**
* @name i18n.routing.strategy
* @type {"pathname"}
* @default `"pathname"`
* @version 3.7.0
* @description
*
* - `"pathanme": The strategy is applied to the pathname of the URLs
*/
strategy: 'pathname';
};
};
experimental?: {
/**
* @docs
@ -1437,122 +1555,6 @@ export interface AstroUserConfig {
*/
optimizeHoistedScript?: boolean;
/**
* @docs
* @name experimental.i18n
* @type {object}
* @version 3.5.0
* @type {object}
* @description
*
* Configures experimental i18n routing and allows you to specify some customization options.
*
* See our guide for more information on [internationalization in Astro](/en/guides/internationalization/)
*/
i18n?: {
/**
* @docs
* @kind h4
* @name experimental.i18n.defaultLocale
* @type {string}
* @version 3.5.0
* @description
*
* The default locale of your website/application. This is a required field.
*
* No particular language format or syntax is enforced, but we suggest using lower-case and hyphens as needed (e.g. "es", "pt-br") for greatest compatibility.
*/
defaultLocale: string;
/**
* @docs
* @kind h4
* @name experimental.i18n.locales
* @type {Locales}
* @version 3.5.0
* @description
*
* A list of all locales supported by the website, including the `defaultLocale`. This is a required field.
*
* Languages can be listed either as individual codes (e.g. `['en', 'es', 'pt-br']`) or mapped to a shared `path` of codes (e.g. `{ path: "english", codes: ["en", "en-US"]}`). These codes will be used to determine the URL structure of your deployed site.
*
* No particular language code format or syntax is enforced, but your project folders containing your content files must match exactly the `locales` items in the list. In the case of multiple `codes` pointing to a custom URL path prefix, store your content files in a folder with the same name as the `path` configured.
*/
locales: Locales;
/**
* @docs
* @kind h4
* @name experimental.i18n.fallback
* @type {Record<string, string>}
* @version 3.5.0
* @description
*
* The fallback strategy when navigating to pages that do not exist (e.g. a translated page has not been created).
*
* Use this object to declare a fallback `locale` route for each language you support. If no fallback is specified, then unavailable pages will return a 404.
*
* ##### Example
*
* The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
*
* ```js
* export default defineConfig({
* experimental: {
* i18n: {
* defaultLocale: "en",
* locales: ["en", "fr", "pt-br", "es"],
* fallback: {
* pt: "es",
* fr: "en"
* }
* }
* }
* })
* ```
*/
fallback?: Record<string, string>;
/**
* @docs
* @kind h4
* @name experimental.i18n.routing
* @type {Routing}
* @version 3.7.0
* @description
*
* Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
*/
routing?: {
/**
* @docs
* @name experimental.i18n.routing.prefixDefaultLocale
* @type {boolean}
* @default `false`
* @version 3.7.0
* @description
*
* When `false`, only non-default languages will display a language prefix.
* The `defaultLocale` will not show a language prefix and content files do not exist in a localized folder.
* URLs will be of the form `example.com/[locale]/content/` for all non-default languages, but `example.com/content/` for the default locale.
*
* When `true`, all URLs will display a language prefix.
* URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
* Localized folders are used for every language, including the default.
*/
prefixDefaultLocale: boolean;
/**
* @name experimental.i18n.routing.strategy
* @type {"pathname"}
* @default `"pathname"`
* @version 3.7.0
* @description
*
* - `"pathanme": The strategy is applied to the pathname of the URLs
*/
strategy: 'pathname';
};
};
/**
* @docs
* @name experimental.contentCollectionCache

View file

@ -270,7 +270,7 @@ async function generatePage(
pipeline.getManifest().base,
pipeline.getManifest().trailingSlash
);
if (config.experimental.i18n && i18nMiddleware) {
if (config.i18n && i18nMiddleware) {
if (onRequest) {
pipeline.setMiddlewareFunction(sequence(i18nMiddleware, onRequest));
} else {
@ -546,7 +546,7 @@ async function generatePath(
logger: pipeline.getLogger(),
ssr,
});
const i18n = pipeline.getConfig().experimental.i18n;
const i18n = pipeline.getConfig().i18n;
const renderContext = await createRenderContext({
pathname,
@ -629,12 +629,12 @@ export function createBuildManifest(
renderers: SSRLoadedRenderer[]
): SSRManifest {
let i18nManifest: SSRManifestI18n | undefined = undefined;
if (settings.config.experimental.i18n) {
if (settings.config.i18n) {
i18nManifest = {
fallback: settings.config.experimental.i18n.fallback,
routing: settings.config.experimental.i18n.routing,
defaultLocale: settings.config.experimental.i18n.defaultLocale,
locales: settings.config.experimental.i18n.locales,
fallback: settings.config.i18n.fallback,
routing: settings.config.i18n.routing,
defaultLocale: settings.config.i18n.defaultLocale,
locales: settings.config.i18n.locales,
};
}
return {

View file

@ -240,12 +240,12 @@ function buildManifest(
entryModules[BEFORE_HYDRATION_SCRIPT_ID] = '';
}
let i18nManifest: SSRManifestI18n | undefined = undefined;
if (settings.config.experimental.i18n) {
if (settings.config.i18n) {
i18nManifest = {
fallback: settings.config.experimental.i18n.fallback,
routing: settings.config.experimental.i18n.routing,
locales: settings.config.experimental.i18n.locales,
defaultLocale: settings.config.experimental.i18n.defaultLocale,
fallback: settings.config.i18n.fallback,
routing: settings.config.i18n.routing,
locales: settings.config.i18n.locales,
defaultLocale: settings.config.i18n.defaultLocale,
};
}

View file

@ -29,9 +29,9 @@ export function shouldAppendForwardSlash(
}
export function i18nHasFallback(config: AstroConfig): boolean {
if (config.experimental.i18n && config.experimental.i18n.fallback) {
if (config.i18n && config.i18n.fallback) {
// we have some fallback and the control is not none
return Object.keys(config.experimental.i18n.fallback).length > 0;
return Object.keys(config.i18n.fallback).length > 0;
}
return false;

View file

@ -318,90 +318,90 @@ export const AstroConfigSchema = z.object({
vite: z
.custom<ViteUserConfig>((data) => data instanceof Object && !Array.isArray(data))
.default(ASTRO_CONFIG_DEFAULTS.vite),
i18n: z.optional(
z
.object({
defaultLocale: z.string(),
locales: z.array(
z.union([
z.string(),
z.object({
path: z.string(),
codes: z.string().array().nonempty(),
}),
])
),
fallback: z.record(z.string(), z.string()).optional(),
routing: z
.object({
prefixDefaultLocale: z.boolean().default(false),
strategy: z.enum(['pathname']).default('pathname'),
})
.default({})
.transform((routing) => {
let strategy: RoutingStrategies;
switch (routing.strategy) {
case 'pathname': {
if (routing.prefixDefaultLocale === true) {
strategy = 'prefix-always';
} else {
strategy = 'prefix-other-locales';
}
}
}
return strategy;
}),
})
.optional()
.superRefine((i18n, ctx) => {
if (i18n) {
const { defaultLocale, locales: _locales, fallback } = i18n;
const locales = _locales.map((locale) => {
if (typeof locale === 'string') {
return locale;
} else {
return locale.path;
}
});
if (!locales.includes(defaultLocale)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The default locale \`${defaultLocale}\` is not present in the \`i18n.locales\` array.`,
});
}
if (fallback) {
for (const [fallbackFrom, fallbackTo] of Object.entries(fallback)) {
if (!locales.includes(fallbackFrom)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The locale \`${fallbackFrom}\` key in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`,
});
}
if (fallbackFrom === defaultLocale) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `You can't use the default locale as a key. The default locale can only be used as value.`,
});
}
if (!locales.includes(fallbackTo)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The locale \`${fallbackTo}\` value in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`,
});
}
}
}
}
})
),
experimental: z
.object({
optimizeHoistedScript: z
.boolean()
.optional()
.default(ASTRO_CONFIG_DEFAULTS.experimental.optimizeHoistedScript),
i18n: z.optional(
z
.object({
defaultLocale: z.string(),
locales: z.array(
z.union([
z.string(),
z.object({
path: z.string(),
codes: z.string().array().nonempty(),
}),
])
),
fallback: z.record(z.string(), z.string()).optional(),
routing: z
.object({
prefixDefaultLocale: z.boolean().default(false),
strategy: z.enum(['pathname']).default('pathname'),
})
.default({})
.transform((routing) => {
let strategy: RoutingStrategies;
switch (routing.strategy) {
case 'pathname': {
if (routing.prefixDefaultLocale === true) {
strategy = 'prefix-always';
} else {
strategy = 'prefix-other-locales';
}
}
}
return strategy;
}),
})
.optional()
.superRefine((i18n, ctx) => {
if (i18n) {
const { defaultLocale, locales: _locales, fallback } = i18n;
const locales = _locales.map((locale) => {
if (typeof locale === 'string') {
return locale;
} else {
return locale.path;
}
});
if (!locales.includes(defaultLocale)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The default locale \`${defaultLocale}\` is not present in the \`i18n.locales\` array.`,
});
}
if (fallback) {
for (const [fallbackFrom, fallbackTo] of Object.entries(fallback)) {
if (!locales.includes(fallbackFrom)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The locale \`${fallbackFrom}\` key in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`,
});
}
if (fallbackFrom === defaultLocale) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `You can't use the default locale as a key. The default locale can only be used as value.`,
});
}
if (!locales.includes(fallbackTo)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The locale \`${fallbackTo}\` value in the \`i18n.fallback\` record doesn't exist in the \`i18n.locales\` array.`,
});
}
}
}
}
})
),
contentCollectionCache: z
.boolean()
.optional()

View file

@ -141,7 +141,7 @@ export async function createVite(
astroPrefetch({ settings }),
astroTransitions({ settings }),
astroDevOverlay({ settings, logger }),
!!settings.config.experimental.i18n && astroInternationalization({ settings }),
!!settings.config.i18n && astroInternationalization({ settings }),
],
publicDir: fileURLToPath(settings.config.publicDir),
root: fileURLToPath(settings.config.root),

View file

@ -18,7 +18,6 @@ import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js';
import { removeLeadingForwardSlash, slash } from '../../path.js';
import { resolvePages } from '../../util.js';
import { getRouteGenerator } from './generator.js';
import { getPathByLocale } from '../../../i18n/index.js';
const require = createRequire(import.meta.url);
interface Item {
@ -491,7 +490,7 @@ export function createRouteManifest(
// Didn't find a good place, insert last
routes.push(routeData);
});
const i18n = settings.config.experimental.i18n;
const i18n = settings.config.i18n;
if (i18n) {
// In this block of code we group routes based on their locale

View file

@ -35,7 +35,7 @@ export default function astroInternationalization({
const trailingSlash = ${JSON.stringify(settings.config.trailingSlash)};
const format = ${JSON.stringify(settings.config.build.format)};
const site = ${JSON.stringify(settings.config.site)};
const i18n = ${JSON.stringify(settings.config.experimental.i18n)};
const i18n = ${JSON.stringify(settings.config.i18n)};
export const getRelativeLocaleUrl = (locale, path = "", opts) => _getLocaleRelativeUrl({
locale,

View file

@ -87,12 +87,12 @@ export default function createVitePluginAstroServer({
*/
export function createDevelopmentManifest(settings: AstroSettings): SSRManifest {
let i18nManifest: SSRManifestI18n | undefined = undefined;
if (settings.config.experimental.i18n) {
if (settings.config.i18n) {
i18nManifest = {
fallback: settings.config.experimental.i18n.fallback,
routing: settings.config.experimental.i18n.routing,
defaultLocale: settings.config.experimental.i18n.defaultLocale,
locales: settings.config.experimental.i18n.locales,
fallback: settings.config.i18n.fallback,
routing: settings.config.i18n.routing,
defaultLocale: settings.config.i18n.defaultLocale,
locales: settings.config.i18n.locales,
};
}
return {

View file

@ -173,7 +173,7 @@ export async function handleRoute({
const config = pipeline.getConfig();
const moduleLoader = pipeline.getModuleLoader();
const { logger } = env;
if (!matchedRoute && !config.experimental.i18n) {
if (!matchedRoute && !config.i18n) {
if (isLoggedRequest(pathname)) {
logger.info(null, req({ url: pathname, method: incomingRequest.method, statusCode: 404 }));
}
@ -190,8 +190,8 @@ export async function handleRoute({
const middleware = await loadMiddleware(moduleLoader);
if (!matchedRoute) {
if (config.experimental.i18n) {
const locales = config.experimental.i18n.locales;
if (config.i18n) {
const locales = config.i18n.locales;
const pathNameHasLocale = pathname
.split('/')
.filter(Boolean)
@ -288,7 +288,7 @@ export async function handleRoute({
filePath: options.filePath,
});
const i18n = pipeline.getConfig().experimental.i18n;
const i18n = pipeline.getConfig().i18n;
renderContext = await createRenderContext({
request: options.request,
@ -307,12 +307,8 @@ export async function handleRoute({
}
const onRequest = middleware?.onRequest as MiddlewareHandler | undefined;
if (config.experimental.i18n) {
const i18Middleware = createI18nMiddleware(
config.experimental.i18n,
config.base,
config.trailingSlash
);
if (config.i18n) {
const i18Middleware = createI18nMiddleware(config.i18n, config.base, config.trailingSlash);
if (i18Middleware) {
if (onRequest) {

View file

@ -2,7 +2,6 @@ import { defineConfig} from "astro/config";
export default defineConfig({
base: "new-site",
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
@ -14,6 +13,5 @@ export default defineConfig({
routing: {
prefixDefaultLocale: true
}
}
}
})

View file

@ -2,7 +2,6 @@ import { defineConfig} from "astro/config";
export default defineConfig({
base: "new-site",
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
@ -13,5 +12,4 @@ export default defineConfig({
pt: "en"
}
}
}
})

View file

@ -1,7 +1,6 @@
import { defineConfig} from "astro/config";
export default defineConfig({
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
@ -13,7 +12,6 @@ export default defineConfig({
routing: {
prefixDefaultLocale: true
}
}
},
},
base: "/new-site"
})

View file

@ -1,14 +1,11 @@
import { defineConfig} from "astro/config";
export default defineConfig({
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
'en', 'pt', 'it'
],
},
i18n: {
defaultLocale: 'en',
locales: [
'en', 'pt', 'it'
],
},
base: "/new-site"
})

View file

@ -1,12 +1,10 @@
import { defineConfig} from "astro/config";
export default defineConfig({
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
'en', 'pt', 'it'
]
}
},
i18n: {
defaultLocale: 'en',
locales: [
'en', 'pt', 'it'
]
}
})

View file

@ -1,7 +1,6 @@
import { defineConfig} from "astro/config";
export default defineConfig({
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
@ -14,5 +13,4 @@ export default defineConfig({
}
]
}
},
})

View file

@ -157,22 +157,20 @@ describe('[DEV] i18n routing', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/i18n-routing-prefix-other-locales/',
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
path: 'spanish',
codes: ['es', 'es-AR'],
},
],
fallback: {
it: 'en',
spanish: 'en',
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
path: 'spanish',
codes: ['es', 'es-AR'],
},
],
fallback: {
it: 'en',
spanish: 'en',
},
},
});
@ -336,25 +334,23 @@ describe('[DEV] i18n routing', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/i18n-routing-fallback/',
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
path: 'spanish',
codes: ['es', 'es-AR'],
},
],
fallback: {
it: 'en',
spanish: 'en',
},
routing: {
prefixDefaultLocale: false,
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
path: 'spanish',
codes: ['es', 'es-AR'],
},
],
fallback: {
it: 'en',
spanish: 'en',
},
routing: {
prefixDefaultLocale: false,
},
},
});
@ -703,22 +699,20 @@ describe('[SSG] i18n routing', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/i18n-routing-fallback/',
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
path: 'spanish',
codes: ['es', 'es-AR'],
},
],
fallback: {
it: 'en',
spanish: 'en',
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
path: 'spanish',
codes: ['es', 'es-AR'],
},
],
fallback: {
it: 'en',
spanish: 'en',
},
},
});
@ -789,16 +783,14 @@ describe('[SSG] i18n routing', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/i18n-routing-prefix-always/',
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
routing: {
prefixDefaultLocale: true,
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
routing: {
prefixDefaultLocale: true,
},
},
});
@ -825,13 +817,11 @@ describe('[SSG] i18n routing', () => {
redirects: {
'/': '/en',
},
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
},
});
@ -856,16 +846,14 @@ describe('[SSG] i18n routing', () => {
build: {
format: 'directory',
},
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
routing: {
prefixDefaultLocale: false,
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
routing: {
prefixDefaultLocale: false,
},
},
});
@ -1115,22 +1103,20 @@ describe('[SSR] i18n routing', () => {
root: './fixtures/i18n-routing-fallback/',
output: 'server',
adapter: testAdapter(),
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
codes: ['es', 'es-AR'],
path: 'spanish',
},
],
fallback: {
it: 'en',
spanish: 'en',
i18n: {
defaultLocale: 'en',
locales: [
'en',
'pt',
'it',
{
codes: ['es', 'es-AR'],
path: 'spanish',
},
],
fallback: {
it: 'en',
spanish: 'en',
},
},
});
@ -1178,16 +1164,14 @@ describe('[SSR] i18n routing', () => {
root: './fixtures/i18n-routing-fallback/',
output: 'server',
adapter: testAdapter(),
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
routing: {
prefixDefaultLocale: false,
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'it'],
fallback: {
it: 'en',
},
routing: {
prefixDefaultLocale: false,
},
},
});
@ -1272,11 +1256,9 @@ describe('[SSR] i18n routing', () => {
root: './fixtures/i18n-routing/',
output: 'server',
adapter: testAdapter(),
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['en_AU', 'pt_BR', 'es_US'],
},
i18n: {
defaultLocale: 'en',
locales: ['en_AU', 'pt_BR', 'es_US'],
},
});
await fixture.build();
@ -1303,16 +1285,14 @@ describe('[SSR] i18n routing', () => {
root: './fixtures/i18n-routing/',
output: 'server',
adapter: testAdapter(),
experimental: {
i18n: {
defaultLocale: 'en',
locales: [
{
path: 'english',
codes: ['en', 'en-AU', 'pt-BR', 'es-US'],
},
],
},
i18n: {
defaultLocale: 'en',
locales: [
{
path: 'english',
codes: ['en', 'en-AU', 'pt-BR', 'es-US'],
},
],
},
});
await fixture.build();
@ -1410,11 +1390,9 @@ describe('i18n routing does not break assets and endpoints', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/core-image-base/',
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es'],
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'es'],
},
base: '/blog',
});

View file

@ -82,11 +82,9 @@ describe('Config Validation', () => {
it('defaultLocale is not in locales', async () => {
const configError = await validateConfig(
{
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['es'],
},
i18n: {
defaultLocale: 'en',
locales: ['es'],
},
},
process.cwd()
@ -100,17 +98,15 @@ describe('Config Validation', () => {
it('errors if codes are empty', async () => {
const configError = await validateConfig(
{
experimental: {
i18n: {
defaultLocale: 'uk',
locales: [
'es',
{
path: 'something',
codes: [],
},
],
},
i18n: {
defaultLocale: 'uk',
locales: [
'es',
{
path: 'something',
codes: [],
},
],
},
},
process.cwd()
@ -122,17 +118,15 @@ describe('Config Validation', () => {
it('errors if the default locale is not in path', async () => {
const configError = await validateConfig(
{
experimental: {
i18n: {
defaultLocale: 'uk',
locales: [
'es',
{
path: 'something',
codes: ['en-UK'],
},
],
},
i18n: {
defaultLocale: 'uk',
locales: [
'es',
{
path: 'something',
codes: ['en-UK'],
},
],
},
},
process.cwd()
@ -146,13 +140,11 @@ describe('Config Validation', () => {
it('errors if a fallback value does not exist', async () => {
const configError = await validateConfig(
{
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['es', 'en'],
fallback: {
es: 'it',
},
i18n: {
defaultLocale: 'en',
locales: ['es', 'en'],
fallback: {
es: 'it',
},
},
},
@ -167,13 +159,11 @@ describe('Config Validation', () => {
it('errors if a fallback key does not exist', async () => {
const configError = await validateConfig(
{
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['es', 'en'],
fallback: {
it: 'en',
},
i18n: {
defaultLocale: 'en',
locales: ['es', 'en'],
fallback: {
it: 'en',
},
},
},
@ -188,13 +178,11 @@ describe('Config Validation', () => {
it('errors if a fallback key contains the default locale', async () => {
const configError = await validateConfig(
{
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['es', 'en'],
fallback: {
en: 'es',
},
i18n: {
defaultLocale: 'en',
locales: ['es', 'en'],
fallback: {
en: 'es',
},
},
},