svelte-i18n cli extract - Typescript support?
See original GitHub issueDescribe the bug
Extracting translations with svelte-i18n extract src/lib/components/Footer.svelte
fails when declaring variable with Typescript’s type.
Tried with --configDir /home/user/work/booking/web
as well.
Logs See stacktraces.
To Reproduce This will fail:
<script lang="ts">
import { _ } from 'svelte-i18n';
export let name: string;
</script>
{$_('test')}
This works:
<script lang="ts">
import { _ } from 'svelte-i18n';
</script>
{$_('test')}
Expected behavior Expect it to work the same in both cases mentioned.
Stacktraces
Stack trace
$ /home/user/work/booking/web/node_modules/.bin/svelte-i18n extract src/lib/components/Footer.svelte /home/user/work/booking/web/node_modules/svelte/compiler.js:16675 const error = new CompileError(message); ^
CompileError [ParseError]: Unexpected token at error (/home/user/work/booking/web/node_modules/svelte/compiler.js:16675:20) at Parser$1.error (/home/user/work/booking/web/node_modules/svelte/compiler.js:16753:10) at Parser$1.acorn_error (/home/user/work/booking/web/node_modules/svelte/compiler.js:16747:15) at Object.read_script [as read] (/home/user/work/booking/web/node_modules/svelte/compiler.js:8799:17) at tag (/home/user/work/booking/web/node_modules/svelte/compiler.js:15701:34) at new Parser$1 (/home/user/work/booking/web/node_modules/svelte/compiler.js:16712:22) at Object.parse$I [as parse] (/home/user/work/booking/web/node_modules/svelte/compiler.js:16844:21) at collectMessages (/home/user/work/booking/web/node_modules/svelte-i18n/dist/cli.js:186:26) at extractMessages (/home/user/work/booking/web/node_modules/svelte-i18n/dist/cli.js:218:5) at /home/user/work/booking/web/node_modules/svelte-i18n/dist/cli.js:269:9 { code: ‘parse-error’, start: { line: 4, column: 20, character: 78 }, end: { line: 4, column: 20, character: 78 }, pos: 78, filename: undefined, frame: “2: import { _ } from ‘svelte-i18n’;\n” + ‘3: \n’ + ‘4: export let name: string;\n’ + ’ ^\n’ + ‘5: \n’ + ‘6: </script>’ }
Information about your project:
"svelte": "^3.44.0",
"svelte-preprocess": "^4.10.7",
"@sveltejs/adapter-auto": "^1.0.0-next.83",
"@sveltejs/kit": "^1.0.0-next.516",
"vite": "^3.1.0",
-
Ubuntu 22.04
-
svelte-i18n
version 3.4.1
Additional context Is there some option I’m missing, or is this a bug? Thank you!
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
Yes, it works perfectly! Thank you so much for your help. Amazing work! 🥇
Can you try again with v3.5.1? I’ve tested in your repro and it worked as expected 🙏 We were missing a small thing while loading the “svelte.config.js” file