fix(editor): translate the patterns count and fall back for new editor strings - #25848
Open
dcalhoun wants to merge 6 commits into
Open
fix(editor): translate the patterns count and fall back for new editor strings#25848dcalhoun wants to merge 6 commits into
dcalhoun wants to merge 6 commits into
Conversation
Contributor
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 33532 | |
| Version | PR #25848 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 1311278 | |
| Installation URL | 76l3qa5e29220 |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 33532 | |
| Version | PR #25848 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 1311278 | |
| Installation URL | 66jtjo56q386g |
dcalhoun
marked this pull request as ready for review
July 28, 2026 19:01
GutenbergKit#569 adds `EditorLocalizableString.patternsCount(Int)`, which is source-breaking for hosts that switch over the enum exhaustively. Track the PR build so the companion changes can land and be tested together. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
GutenbergKit#569 adds `patternsCount(Int)`, which previously rendered as a hardcoded English string. Translate it, splitting singular and plural so each reads naturally. Also delegate unhandled keys to `EditorLocalization.defaultLocalize(_:)`. The switch was exhaustive, so every string the editor added broke this build until someone wrote a translation — and the break surfaced on the dependency bump, not when the string was added. New keys now render in English until translated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A plain `default` warns "default will never be executed" because this switch covers every case the pinned GutenbergKit defines. `@unknown default` compiles clean and behaves the same once the editor adds a string. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
GutenbergKit#569 changed `EditorLocalization.localize` to return `String?`.
Hosts now decline a key by returning `nil` instead of calling a public
`defaultLocalize`, so the editor supplies the string and reports the gap.
`getLocalizedString(for:)` and `EditorLocalizableString.localized` return
`String?`, and the fallback case yields `nil`. The install site in
PostGBKEditorViewController needs no change: `{ $0.localized }` already
matches the new closure type.
Keeps the `@unknown default` from 88bbcf4. It stays reachable only for
keys a future GutenbergKit adds; every case defined today is still handled
explicitly, so the pattern count keeps its own translation rather than
falling through.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
dcalhoun
force-pushed
the
fix/gutenbergkit-localization-fallback
branch
from
July 29, 2026 19:19
786e07d to
1311278
Compare
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.


Description
Adopts GutenbergKit#569, which localizes the block inserter's pattern count and lets host apps fall back to the editor's own strings for keys they do not translate.
Two changes here:
Translate
patternsCount. GutenbergKit#569 addsEditorLocalizableString.patternsCount(Int)for a string that previously rendered as hardcoded English. Singular and plural are split so each reads naturally rather than forcing "1 pattern(s)".Decline unhandled keys.
getLocalizedString(for:)switched over the enum exhaustively, so every string the editor added broke this build until someone wrote a translation — and the break surfaced on the dependency bump, not when the string was added. Unhandled keys now returnnil, and the editor supplies its own string:New editor strings render in English until translated, instead of failing to compile.
@unknown defaultrather than a plaindefaultbecause this switch currently covers every case, and a plain one warns "default will never be executed."EditorLocalization.localizenow returnsString?, sogetLocalizedString(for:)andEditorLocalizableString.localizedreturn optionals to match. The install site inPostGBKEditorViewControlleris unchanged —{ $0.localized }already fits the new closure type.Note that
@unknown defaultcovers only keys added by a future GutenbergKit. Skipping a case that exists today is still a compile error, so this cannot silently drop a translation we meant to write.Note
Modules/Package.swiftpins a GutenbergKit revision while that PR is open. TheTODOthere marks restoring a version pin once it ships. This PR should not merge before GutenbergKit#569.Testing instructions
The pattern count is the visible change:
To verify the fallback, which has no visible effect until GutenbergKit adds a string:
getLocalizedString(for:)—.patternsor.searchrender unconditionally and are easy to spot. Returnnilfor it instead, since removing the case outright is a compile error.[GutenbergKit:localization] Missing host translation for …, or filter Console.app on subsystemGutenbergKit. Each key reports once per launch, so scrolling a list will not repeat it.Nothing reports with every case handled, which is the expected state on
trunk.