From 7a6325b8a50d6163db6c4e5437b6f4efdd87fc7c Mon Sep 17 00:00:00 2001 From: Sahin Vardar Date: Fri, 9 Jun 2023 15:43:29 +0200 Subject: [PATCH] fix: param path keys --- assets/example/routes/users/[userId]/+page.svelte | 5 +++++ assets/translations/de.csv | 1 + assets/translations/en.csv | 1 + package.json | 2 +- src/extract-i18n-keys.test.ts | 3 ++- src/extract-i18n-keys.ts | 2 +- 6 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 assets/example/routes/users/[userId]/+page.svelte diff --git a/assets/example/routes/users/[userId]/+page.svelte b/assets/example/routes/users/[userId]/+page.svelte new file mode 100644 index 0000000..c958993 --- /dev/null +++ b/assets/example/routes/users/[userId]/+page.svelte @@ -0,0 +1,5 @@ +
+
+ {$i18n('user-message')} +
+
\ No newline at end of file diff --git a/assets/translations/de.csv b/assets/translations/de.csv index 07516d0..06605f2 100644 --- a/assets/translations/de.csv +++ b/assets/translations/de.csv @@ -8,3 +8,4 @@ routes.layout.header;xxxTODOxxx routes.page.intro;xxxTODOxxx routes.page.known-from;xxxTODOxxx routes.team.page.team-intro;xxxTODOxxx +routes.users.userId.page.user-message;xxxTODOxxx diff --git a/assets/translations/en.csv b/assets/translations/en.csv index 07516d0..06605f2 100644 --- a/assets/translations/en.csv +++ b/assets/translations/en.csv @@ -8,3 +8,4 @@ routes.layout.header;xxxTODOxxx routes.page.intro;xxxTODOxxx routes.page.known-from;xxxTODOxxx routes.team.page.team-intro;xxxTODOxxx +routes.users.userId.page.user-message;xxxTODOxxx diff --git a/package.json b/package.json index e438281..07d1dec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vardario/svelte-i18next", - "version": "0.1.7", + "version": "0.1.8", "description": "", "license": "MIT", "author": "Sahin Vardar", diff --git a/src/extract-i18n-keys.test.ts b/src/extract-i18n-keys.test.ts index 0958f6e..e7423dd 100644 --- a/src/extract-i18n-keys.test.ts +++ b/src/extract-i18n-keys.test.ts @@ -21,7 +21,8 @@ describe('extract-i18n-keys', () => { 'routes.layout.header', 'routes.page.intro', 'routes.page.known-from', - 'routes.team.page.team-intro' + 'routes.team.page.team-intro', + 'routes.users.userId.page.user-message' ].sort() ); }); diff --git a/src/extract-i18n-keys.ts b/src/extract-i18n-keys.ts index 4a4dc38..4839c7f 100644 --- a/src/extract-i18n-keys.ts +++ b/src/extract-i18n-keys.ts @@ -49,7 +49,7 @@ export async function processSvelteFile( const addKeyPath = (key: string) => { const path = extractKeyPathFromFile(filename); - return `${path}.${key}`; + return `${path}.${key}`.replace(/\[|\]/g, ''); }; return keys.map(addKeyPath);