Skip to content

Commit

Permalink
fix: fixed Regxp extractor to format all locales words #77
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgarciaesgi committed Mar 6, 2023
1 parent f576eab commit c08765f
Show file tree
Hide file tree
Showing 9 changed files with 816 additions and 227 deletions.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"@nuxt-themes/docus": "1.8.3",
"nuxt": "3.2.2"
"nuxt": "3.2.3"
}
}
1,016 changes: 803 additions & 213 deletions docs/yarn.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"@nuxtjs/i18n": "8.0.0-beta.9",
"@nuxtjs/web-vitals": "^0.2.2",
"@types/lodash-es": "^4.17.6",
"@types/mkdirp": "^2.0.0",
"@types/node": "^18.14.0",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.53.0",
Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineNuxtConfig({
i18n: {
locales: [
{ code: 'en', name: 'en' },
{ code: 'fr', name: 'fr' },
{ code: 'fr-FR', name: 'fr' },
],
defaultLocale: 'en',
strategy: 'prefix_and_default',
Expand Down
Empty file removed playground/src/pages/[foo].vue
Empty file.
1 change: 1 addition & 0 deletions playground/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const localeRoute = useLocaleRoute();
function navigate() {
router.push({ name: 'user-id-slug', params: { slug: 'bar', id: 1 } });
router.push('/fr-FR?bar');
router.push(localePath('/admin/888'));
Expand Down
10 changes: 1 addition & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/parser/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function constructRouteMap(routesConfig: NuxtPage[]): GeneratorOutput {

return output;
} catch (e) {
throw new Error('Generation failed', e as any);
throw new Error(`Generation failed: ${e}`);
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/core/parser/i18n.modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export function hasi18nSibling(
return (
route.name?.match(new RegExp(`^(${rt.name})${separator}[a-zA-Z]+`, 'g')) ||
(rt.path !== '/' &&
route.path?.match(new RegExp(`/?[${i18nLocales?.join('|')}]${rt.path}`, 'g')))
route.path?.match(
new RegExp(
`/?[${i18nLocales?.map((m) => m.replace(/[^a-zA-Z0-9_]/gm, '\\$&')).join('|')}]${
rt.path
}`,
'g'
)
))
);
});
}
Expand Down

1 comment on commit c08765f

@vercel
Copy link

@vercel vercel bot commented on c08765f Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.