Repository navigation
Fix layers going blank when linked to a plural message, link review gaps, drop unused manifest domain - #78
Merged
Conversation
…aps, drop unused manifest domain - A layer linked to a message with forms (plural, select) looked its text up with a match of [], which only finds an all-catch-all form. Files that import "other" as a literal match (Inlang message format, i18next) have none, so the layer went blank, showed "Revert / Update message" and "Update message" would have written into no form; editing its text in the Layers tab threw. A layer now shows the form its own stored variable values choose (plugin data pv): a count picks the plural category of the language, a select picks its value, the catch-all form is the default and a layer never ends up without text. A plural starts with an example count (or the number its text shows when it is linked) and the count can be edited under the layer's text. - The link review after importing a translation depended on which keys the file had: layers in reference-language frames are now matched against every message, and a message that is not translated to a frame's language is found by its reference text (also for "Generate keys"). - A placeholder at the very start of a layer text was cut out of the styled text range by nobody: the editor showed the whole text plus the placeholder after it and the layer looked modified. - Remove https://s3-alpha.figma.com from the network access: only the hidden Users view used it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… plural types, formatting of reference-text links
- A form without the number in its text ("One item") kept its inferred count only on paper: the
default filler replaced it with the example count. The guessed count is now a real value.
- The example count no longer changes when a layer is switched to another language (a number stays,
the plural rules of the language choose the form); examples are whole numbers and skip exact
numbers (=2).
- i18next plurals with `type=$pluralType` (ordinal and cardinal forms) read the type from the layer.
- No form that fits a language gives no variant (not the first one): the layer falls back to the
reference text of the same count, and to any text of the message as the last resort.
- Layers linked through the reference-text fallback keep their formatting (planLinks) and never
rewrite the message; markup around a number is no value; mixed exact-number / category selectors
are plurals.
- toSandboxUpdate no longer changes the cached label's values in place; "Update message" is awaited so
a message that needs the Messages tab reports its error; the count field is read-only while the layer
text is modified (a new value would replace the text).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
What this fixes
1. A layer linked to a plural message went blank
Linking a text layer to a plural message (e.g.
checkout.items, formsone/other, variablecount) left the layer empty, showed "Revert" / "Update message" and made editing the layer text in the Layers tab throw.Root cause: every layer lookup asked the message for the form with a match of
[], which only finds an all catch-all form. Files imported with the Inlang message format or i18next storeotheras a literal match (countPlural=other), so there was no such form, the lookup returnedundefinedandtoSandboxUpdatewrote?? ""to the canvas. Thecountvalue of the layer could not be edited anywhere (the parameter editor of the Layers row has been a TODO since the selector rewrite), andUpdate message/ the language switch looked for / wrote forms with the same[]match.What a designer sees now:
pv, like every other variable): a plural count picks the plural category of the frame language (1->one,5->other, Russian2->few), exact numbers (ICU=0) win, a select (gender) picks its value, and without a value the layer shows the catch-all (other) form. A message without any text for the layer leaves the layer's text alone instead of blanking it.{count} itemsbecomescount= 7 and keeps "7 items"; "1 item" keeps its form. A layer whose text is no form gets an example count ("2 items") instead of "count items".count [ 2 ]field under the layer's text (a select shows e.g.gender [ female ], empty = "other" form). Editing it is one undo step, writes only the layer (not the message) and the layer follows in every language it is switched to.{count} items) was listed by the sandbox as an extra overlapping range, so the editor showed "2 items" plus a straycountchip and the layer looked modified.toQuillTextOperationsnow cuts the placeholder out of the style range (pure UI-side change, the sandbox bundle is unchanged).New module
src/lib/message/LayerVariant.ts(form choice, example/inferred values), used byhtmlForLayer,getState, the language switch,Update messageandtoSandboxUpdate.2. Link review depended on other languages being complete
After importing a French file that lacks
checkout.free_delivery, the review "Link layers to the imported messages?" no longer offered the layer with the English reference text of that message (reproduced live). Two causes:3. Manifest
https://s3-alpha.figma.com(Figma profile pictures) is removed fromallowedDomainsand thereasoningtext inmanifest.jsonandmanifest.figma.ts. Its only consumer is<img src={user.photoUrl}>inUsermanagement.tsx, which is only rendered forappScreen === "users"; the tab is commented out since the commit that added it (2023), so no code path can set it (not even a storedlastView). A test pins it.Verification
origin/dev, pass here):LayerVariant.test.ts(imports through the real plugins: Inlang message format incl. thecount=one/otherform, i18next, ICU, next-intl),LocalizedLabelManagerUI.test.ts,UILocalizedLabel.test.ts,LinkSuggestions.test.ts,RichTextFormatting.test.ts,manifest.test.ts.pnpm tsc && pnpm lint && pnpm test && pnpm buildand the sandbox build pass (the sandbox bundle is byte-identical in size toorigin/dev).pvtogether, French shows "5 articles", select values switch forms, "Update message" writes only theotherform, the French import review now offers the free-delivery layer, a layer in a French frame is found, the Layers row aligns with the text.Not changed / notes
Layers left blank by the old bug (message linked, text empty) are not repaired automatically; "Revert" in the row now restores their text.
Editing the
countchip inside the layer text only changes the value shown, not the form; use the count field.The count field is read-only while the layer text is modified (a new value would replace the edited text): use "Update message" or "Revert" first.
After a translation import the review also offers unlinked reference-language layers that match any existing message (not only keys of the file). Layers the designer declined at an earlier import can show up again; this is deliberate (what is offered no longer depends on how complete the file is).
Review
A read-only review sub-agent went through the diff; confirmed findings were fixed in a7ab810 (inferred "One item" count, stable example counts across languages,
type=$pluralTypeordinals, strict form lookup with reference fallback, formatting of reference-text links, in-place mutation of the cached label values, un-awaited "Update message", markup captured as a value). Tests were added for each.🤖 Generated with Claude Code