Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(i18n): ignore i18n modifiers #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading