Localization: wrap non-translatable SwiftUI Text literals + document the rule (prep for swiftui: true)#25701
Open
jkmassel wants to merge 2 commits into
Open
Localization: wrap non-translatable SwiftUI Text literals + document the rule (prep for swiftui: true)#25701jkmassel wants to merge 2 commits into
jkmassel wants to merge 2 commits into
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32873 | |
| Version | PR #25701 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 1567c89 | |
| Installation URL | 5t3q4vjpd3bto |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32873 | |
| Version | PR #25701 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 1567c89 | |
| Installation URL | 6ut28kgm75geo |
Text literals to Text(verbatim:)Text literals to verbatim (+ CI lint for previews)
Text literals to verbatim (+ CI lint for previews)Text(verbatim:) for SwiftUI preview strings + CI lint
Text(verbatim:) for SwiftUI preview strings + CI lintd91db67 to
cee64c6
Compare
`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.
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.


Summary
Prep for enabling SwiftUI string extraction (
swiftui: trueongenerate_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 thevisibility/synccontract: previews and#if DEBUGare auto-excluded (noverbatim:needed);Text(verbatim:)is for non-translatable literals in shipping code.2. Cleanup (38 files)
Text("…")→Text(verbatim:): glyphs/separators (·,—," • ",Aa), brand names (WordPress.com), pure string interpolations (@\(username)), HTTP status codes, and developer/debug-screen text.Text("\(count)")ships unlocalized digits — no grouping, no locale numerals):Text(count, format: .number),Text(Double(progress) / 100, format: .percent), and.formatted()inside averbatim:wrapper for decorated counts.Left translatable on purpose
Real UI strings, the
^[%@](inflect: true)string (relies onLocalizedStringKeyinflection), andexample.com(the site-address placeholder).Out of scope (follow-ups)
verbatim:-until-shipped — TBD).Overriden→Overriddencodebase-wide misspelling (enum case,isOverriden(), and a GlotPress key — a rename)."%@ characters"strings (deserve proper plurals).TODO:placeholder inActivityLogDetailView's share sheet (an unfinished feature).Test plan
verbatim:renders identically; the number formatters localize.swiftc -parseclean across all changed files.xcstringstool extract --SwiftUI-Text: shippingText("…")extraction drops 69 → 15, and the remaining 15 are all intentionally translatable.Related: #25700, #25688