HenryLie / svelte-i18n-lingui

Use lingui for i18n in Svelte/Sveltekit projects
https://www.npmjs.com/package/svelte-i18n-lingui
MIT License
23 stars 2 forks source link

`gt` does not work on string literals #6

Open blinry opened 1 year ago

blinry commented 1 year ago

We tried using a line like

gt("test")

in a TS file, and the jstsExtractor didn't catch it. We checked the code, and it seems that it currently only works on expressions like this:

gt({message: "test"})

Would it make sense to also allow gt to take plain strings? Thanks!

blinry commented 1 year ago

Oh! We learned that

gt`test`

works! What does this syntax mean?

HenryLie commented 1 year ago

Hey, thanks for trying out the lib!

I made gt syntax mostly the same as $t would in Svelte components, so it can accept either of these two forms:

Let me know if you have any other question 😄

blinry commented 1 year ago

Makes sense! I'd suggest adding an example using gt`foo` to the README, so others will be less stumped than us! :D

Ohh, and that you can drop the parens is some some nice syntactic sugar, thanks for the explanation!