Skip to content

Localization: wrap non-translatable SwiftUI Text literals + document the rule (prep for swiftui: true)#25701

Open
jkmassel wants to merge 2 commits into
trunkfrom
issue-25700
Open

Localization: wrap non-translatable SwiftUI Text literals + document the rule (prep for swiftui: true)#25701
jkmassel wants to merge 2 commits into
trunkfrom
issue-25700

Conversation

@jkmassel

@jkmassel jkmassel commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Prep for enabling SwiftUI string extraction (swiftui: true on generate_strings_catalog). Two complementary parts: document the rule for non-translatable SwiftUI text, and apply it to the codebase's shipping literals so they don't reach GlotPress as garbage once extraction is on.

Changes

1. Docs (docs/localization.md) — document the visibility / sync contract: previews and #if DEBUG are auto-excluded (no verbatim: needed); Text(verbatim:) is for non-translatable literals in shipping code.

2. Cleanup (38 files)

  • 36 Text("…")Text(verbatim:): glyphs/separators (·, , " • ", Aa), brand names (WordPress.com), pure string interpolations (@\(username)), HTTP status codes, and developer/debug-screen text.
  • 6 numeric interpolations → locale-aware formatting (a bare Text("\(count)") ships unlocalized digits — no grouping, no locale numerals): Text(count, format: .number), Text(Double(progress) / 100, format: .percent), and .formatted() inside a verbatim: wrapper for decorated counts.

Left translatable on purpose

Real UI strings, the ^[%@](inflect: true) string (relies on LocalizedStringKey inflection), and example.com (the site-address placeholder).

Out of scope (follow-ups)

  • The unwired Realtime / Insights / Subscribers strings (verbatim:-until-shipped — TBD).
  • The OverridenOverridden codebase-wide misspelling (enum case, isOverriden(), and a GlotPress key — a rename).
  • The two "%@ characters" strings (deserve proper plurals).
  • A TODO: placeholder in ActivityLogDetailView's share sheet (an unfinished feature).

Test plan

  • No behavior change — verbatim: renders identically; the number formatters localize.
  • swiftc -parse clean across all changed files.
  • Verified with xcstringstool extract --SwiftUI-Text: shipping Text("…") extraction drops 69 → 15, and the remaining 15 are all intentionally translatable.

Related: #25700, #25688

@dangermattic

dangermattic commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.

Generated by 🚫 Danger

@jkmassel jkmassel marked this pull request as draft June 25, 2026 01:22
@wpmobilebot

wpmobilebot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32873
VersionPR #25701
Bundle IDcom.jetpack.alpha
Commit1567c89
Installation URL5t3q4vjpd3bto
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32873
VersionPR #25701
Bundle IDorg.wordpress.alpha
Commit1567c89
Installation URL6ut28kgm75geo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jkmassel jkmassel changed the title Localization: convert non-translatable SwiftUI Text literals to Text(verbatim:) Localization: convert non-translatable SwiftUI Text literals to verbatim (+ CI lint for previews) Jun 25, 2026
@jkmassel jkmassel changed the title Localization: convert non-translatable SwiftUI Text literals to verbatim (+ CI lint for previews) Localization: use Text(verbatim:) for SwiftUI preview strings + CI lint Jun 25, 2026
@jkmassel jkmassel changed the title Localization: use Text(verbatim:) for SwiftUI preview strings + CI lint Localization: exclude SwiftUI preview strings from translation + CI lint (narrowed scope) Jun 25, 2026
@jkmassel jkmassel force-pushed the issue-25700 branch 3 times, most recently from d91db67 to cee64c6 Compare June 26, 2026 17:24
@jkmassel jkmassel marked this pull request as ready for review June 26, 2026 17:43
@jkmassel jkmassel requested a review from a team as a code owner June 26, 2026 17:43
@jkmassel jkmassel changed the title Localization: exclude SwiftUI preview strings from translation + CI lint (narrowed scope) Localization: document that xcstringstool sync excludes preview / #if DEBUG strings Jun 26, 2026
jkmassel added 2 commits June 26, 2026 13:05
`xcstringstool` tags each extracted string with its compile gate (`visibility`);
`sync` admits only unconditional strings into the catalog, so `#Preview` /
`PreviewProvider` / `#if DEBUG` literals are excluded automatically — no
`verbatim:` needed. Document this, and that `Text(verbatim:)` is for
non-translatable literals in shipping code (glyphs, brands, pure interpolations).
…wiftui: true)

Once SwiftUI string extraction is enabled (`swiftui: true` on
generate_strings_catalog), `xcstringstool extract --SwiftUI-Text` pulls every
shipping `Text("literal")` into the String Catalog for translation — including
non-translatable literals that would reach GlotPress as garbage. Wrap those in
`Text(verbatim:)`, and fix a few numeric cases to format per the user's locale.
No behavior change.

- Glyphs/separators, brand names, pure string interpolations, HTTP status codes,
  and developer/debug-screen text -> `Text(verbatim:)`.
- Bare numeric interpolations -> locale formatters: `Text(count, format: .number)`,
  `Text(Double(progress) / 100, format: .percent)`, and `.formatted()` inside a
  verbatim wrapper for decorated counts. A bare `Text("\(count)")` ships
  unlocalized digits (no grouping, no locale numerals).

Left translatable on purpose: real UI strings, the `^[%@](inflect:)` string
(LocalizedStringKey inflection), and `example.com` (site-address placeholder).

Out of scope (separate changes): the unwired Realtime/Insights/Subscribers
strings, the `Overriden`->`Overridden` codebase-wide misspelling, the two
`"%@ characters"` strings (want proper plurals), and a `TODO:` placeholder in
ActivityLogDetailView's share sheet.
@jkmassel jkmassel changed the title Localization: document that xcstringstool sync excludes preview / #if DEBUG strings Localization: wrap non-translatable SwiftUI Text literals + document the rule (prep for swiftui: true) Jun 26, 2026
@jkmassel jkmassel requested a review from crazytonyli June 26, 2026 19:22
@jkmassel jkmassel self-assigned this Jun 26, 2026
@jkmassel jkmassel added this to the 27.1 milestone Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants