From 230fc13b63c6ee2d31c001c5cff8bba012a9e872 Mon Sep 17 00:00:00 2001 From: Sahin Vardar Date: Mon, 3 Jul 2023 18:02:48 +0200 Subject: [PATCH] fix: supporting groups in routing parts (#16) --- assets/example/routes/{ => (public)}/about/+page.svelte | 0 package.json | 2 +- src/extract-i18n-keys.test.ts | 2 +- src/string-utils.ts | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename assets/example/routes/{ => (public)}/about/+page.svelte (100%) diff --git a/assets/example/routes/about/+page.svelte b/assets/example/routes/(public)/about/+page.svelte similarity index 100% rename from assets/example/routes/about/+page.svelte rename to assets/example/routes/(public)/about/+page.svelte diff --git a/package.json b/package.json index a50c68e..8d1b53e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vardario/svelte-i18next", - "version": "0.1.15", + "version": "0.1.16", "description": "", "license": "MIT", "author": "Sahin Vardar", diff --git a/src/extract-i18n-keys.test.ts b/src/extract-i18n-keys.test.ts index 96d6a66..6d773f7 100644 --- a/src/extract-i18n-keys.test.ts +++ b/src/extract-i18n-keys.test.ts @@ -8,7 +8,7 @@ describe('extract-i18n-keys', () => { const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); const exampleDir = path.resolve(__dirname, '../assets/example'); - const keys = await extractI18NextKeys([exampleDir]); + const keys = await extractI18NextKeys([exampleDir]); expect(keys.sort()).toStrictEqual( [ diff --git a/src/string-utils.ts b/src/string-utils.ts index 6391712..cea5093 100644 --- a/src/string-utils.ts +++ b/src/string-utils.ts @@ -23,5 +23,5 @@ export function extractKeyPathFromFile(filename: string) { const index = pathParts.findIndex(pathPart => regEx.exec(pathPart)); const result = pathParts.slice(index).join('.'); - return result.replace('.svelte', '').replace('+', '').replace(/\[|\]/g, ''); + return result.replace('.svelte', '').replace('+', '').replace(/\[|\]/g, '').replace(/\((.+)\)\./, ''); }