Repository navigation
fix(builtins): follow svelte-i18n stores read with get() - #159
Open
erkamyaman wants to merge 2 commits into
Open
erkamyaman wants to merge 2 commits into
erkamyaman wants to merge 2 commits into
Conversation
|
@erkamyaman is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
`get(_)('key')`, `const translate = get(_)` and stores imported under another
name (`import { _ as i18n }` with `$i18n` or `get(i18n)`) were not usages, so
working keys showed up as unused. `get(otherStore)` is still not a translator.
- core: `CallSpec.unwrap` names the functions that read a store callee
- js scanner: resolve `reader(store)` calls and aliases, and `$name` for stores
- svelte scanner: scan scripts first and share their bindings with the template
- svelte-i18n: `_`, `t`, `format`, `json` are stores read with `get`
Refs x18n-dev#155
erkamyaman
force-pushed
the
fix/svelte-i18n-get-store
branch
from
November 13, 2026 11:16
cff2c79 to
0505d9c
Compare
A key held in a constant of a component's `<script>` and used in its markup
(`const key = 'greeting'` with `{$_(key)}`) read as a fully dynamic usage, so
the key showed up as unused. Constants now live in the scope the script and
template scans share, with the offset of the scan that declared them, so the
usage points at the literal in the script.
Fixes x18n-dev#157
Member
|
Also add Fixes #157 to the body so it closes on merge! ❤️ |
Member
Author
thx, i must have missed this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #155
Fixes #157
get(_)('key'),const translate = get(_)and renamed store imports (import { _ as i18n }with$i18norget(i18n)) were not counted as usages, so working keys showed up as unused.get(otherStore)is still not treated as a translator.Changes
CallSpec.unwrapoption: the functions that read a store callee (['get']). Schema, API snapshot, plan and docs updated.get(store)('key'),const tr = get(store), a renamedgetimport, and$namefor a store bound toname.<script>blocks first and shares their bindings with template expressions, so{tr('key')}works whentris declared in the script._,t,format,jsonare stores read withget;$_,$t,$format,$jsonstay plain calls.Tests
scanners.test.ts: store reads, aliases, renamed imports, and negatives (get(otherStore),get(_, 'x')).presets.test.ts: the cases from the issue in a.tsfile and a.sveltecomponent.The
unwraprow indocs/content/6.references/1.config.mdwas written by hand; the docs generator couldn't run locally, sogenerate --checkmay want a small touch-up.