cibernox / svelte-intl-precompile

I18n library for Svelte.js that analyzes your keys at build time for max performance and minimal footprint
https://svelte-intl-precompile.com
ISC License
274 stars 13 forks source link

Keys with dots (periods) are not found. #47

Closed jhubbardsf closed 2 years ago

jhubbardsf commented 2 years ago

I'm migrating my project over from svelte-i18n to here and noticed that any key with a dot is not found. So if I had

{
    "title.1": "This is title one",
    "title.2": "This is title two"
}

the values are not found by this library, although they're valid JSON and work with svelte-i18n. This library would want it in this format.

{
    "title": {
        "1": "This is title one",
        "2": "This is title two"
    }
}

But $_('title.1') only finds the second example in this library, not the first. Wouldn't be a huge issue to refactor by code to work with this. But in some cases it does get a little complex. Since this is largely a drop in improvement for svelte-i18n, I just wanted to bring this up. I haven't had time to look through the code to figure out exactly why this would be happening here yet.

Edit: I've fixed the issue which was in precompile-intl-runtime here. If that's merged in and the version for precompile-int-runtime here is bumped then the keys should be parsed the exact same as svelte-i18n and be a better drop in replacement.

cibernox commented 2 years ago

Keys with dots should work. In fact is the style I use and it has been working for me. Can you share a bit more about your setup?

jhubbardsf commented 2 years ago

Huh, that's odd, because until I made the change in precompile-intl-runtime and used it locally, my stuff was saying it couldn't find the keys. Let me try to recreate it in a fresh repository.

jhubbardsf commented 2 years ago

So darnedest thing. I've been working on our international refactor for a while and now I can't reproduce it. I'll close this and the PR. If I end up being able to reproduce it I'll reopen!