Skip to content

Commit

Permalink
fix(i18n): added ignore i18n option
Browse files Browse the repository at this point in the history
  • Loading branch information
Alolu committed Jun 19, 2024
1 parent 673762d commit 030c4bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/core/config/moduleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ModuleOptionsStore {
i18nOptions: NuxtI18nOptions | null = null;
i18nLocales: string[] = [];
ignoreRoutes: string[] = [];
ignoreI18nModifiers: boolean = false;

updateOptions(options: ModuleOptions & CustomNuxtConfigOptions) {
if (options.plugin != null) this.plugin = options.plugin;
Expand Down Expand Up @@ -65,6 +66,9 @@ class ModuleOptionsStore {
if (options.ignoreRoutes) {
this.ignoreRoutes = options.ignoreRoutes;
}
if (options.ignoreI18nModifier) {
this.ignoreI18nModifiers = options.ignoreI18nModifier;
}

if (options.isDocumentDriven) {
this.ignoreRoutes.push('[...slug].vue');
Expand Down
4 changes: 2 additions & 2 deletions src/core/parser/i18n.modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export function is18Sibling(source: RoutePathsDecl[], route: NuxtPage) {
}

export function modifyRoutePrefixDefaultIfI18n(route: NuxtPage) {
const { i18n, i18nOptions, i18nLocales } = moduleOptionStore;
if (i18n && i18nOptions && route.name) {
const { i18n, i18nOptions, i18nLocales, ignoreI18nModifiers } = moduleOptionStore;
if (i18n && i18nOptions && route.name && !ignoreI18nModifiers) {
const separator = i18nOptions?.routesNameSeparator ?? '___';
const i18LocalesRecognizer = i18nLocales
?.map((m) => m.replace(specialCharacterRegxp, '\\$&'))
Expand Down
5 changes: 5 additions & 0 deletions src/types/config.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export interface ModuleOptions {
* Ex: 404 routes or catchAll routes
*/
ignoreRoutes?: string[];
/**
* Ignores i18n modifiers when generating typed routes
* @default false
*/
ignoreI18nModifier?: boolean;
}

export interface StrictOptions {
Expand Down

0 comments on commit 030c4bd

Please sign in to comment.