New action: localization placeholder-compatibility check (catch placeholder-breaking changes to existing keys)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- android, ios, ruby
- 领域
- localization, release, tooling
调研方向
首先查看现有的 ios_lint_localizations、L10nLinterHelper、an_validate_lib_strings 和 StringsFileValidationHelper 实现,然后检查 common/ 和 ios_/android_ 的 action 结构。添加 pure-Ruby signature 和 diff 原语、平台包装器、针对所列示例和边界情况的 RSpec 覆盖,以及所要求的文档和 CHANGELOG 更新。当验收标准通过且 signature 输出与给出的示例一致时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Summary
Add a reusable placeholder-shape primitive plus an action that fails when an existing localization key's source-language value changes its format placeholders — count, position, or argument type — between two versions of the source strings. Such a change silently breaks every existing translation for that key.
This is a different axis from ios_lint_localizations, which compares each translation against the base language at a single point in time. This compares base ↔ base across versions (temporal).
Filed for the WordPress-iOS continuous-localization work ("Faster Releases" RFC). Reference implementation: wordpress-mobile/WordPress-iOS#25675 —
fastlane/helpers/string_placeholders.rb+ thevalidate_string_placeholderslane. WPiOS will adopt the toolkit version once it lands and delete the project-side copy.
Motivation
The continuous-localization model uploads regenerated source strings on every trunk merge and downloads whatever human translations exist daily — so whatever translations exist ship as-is. That is only safe if a translation key is never reused for placeholder-incompatible copy:
- GlotPress (and most TMS) key translations by the source string's key, not its current English text.
- If a key's English changes from
"%1$@ liked your post"to"%1$d people liked your post"(object → int), existing translations stay under the same key, and the app formats the new call site'sIntargument with a translation that still expects an object → wrong output or a crash.
Today this invariant is convention-only. We need an automated guardrail in CI.
The invariant
For every key present in both the previous and the newly-generated source-language strings, the set/sequence of format specifiers — accounting for positional args and argument type — must be identical. New and removed keys are ignored: copy that needs a fresh translation is expected to land under a new key (which shows up as remove-old + add-new).
Proposed API
1. Reusable primitive (the important part — also consumed by the companion AI-translation backfill issue)
A platform-agnostic helper operating on raw strings / { key => value } hashes:
placeholder_signature(value) -> String— canonical signature of the placeholders in a string (''if none).placeholders_compatible?(a, b) -> Boolean—signature(a) == signature(b).incompatible_placeholder_changes(old_hash, new_hash) -> Array<Hash>— keys present in both whose signature differs, each{ key:, old:, new:, old_signature:, new_signature: }.
2. Action
A Fastlane action that fails (or reports) on incompatible changes between two versions of a base strings file. Suggested options (mirroring ios_lint_localizations):
| Option | Description |
|---|---|
old_file / new_file |
Paths to the previous and newly-generated base strings. |
abort_on_violations |
Abort the lane on any violation (default true). |
allow_retry |
Interactive retry prompt (parity with ios_lint_localizations). |
The signature algorithm (please implement exactly)
The signature must be invariant to benign copy edits and to reordering equivalent positional args, but sensitive to count/position/type changes.
- Extract format specifiers with a printf/NSString regex:
%, optional positionalN$, flags[-+ 0#], width,.precision, length modifier (hh|h|ll|l|q|L|z|t|j), conversion char[@diouxXeEfgGaAcCsSpn%]. - Skip
%%(literal percent — not a placeholder). - Map the conversion char to an argument-type CLASS (so
%d↔%iare compatible but%d↔%@are not):@→objectd i u o x X→inte E f g G a A→floatc C→chars S→cstringp→pointer
- Key each specifier by position: explicit (
%1$@→ 1) or, for non-positional specifiers, by appearance order (1, 2, 3…). Sort by position, render each asposition:class, join with,. Empty string if there are no specifiers.
Worked examples
| Value | Signature |
|---|---|
Just text |
(empty) |
Hello %@ |
1:object |
%1$d items in %2$@ |
1:int,2:object |
%2$@ told by %1$@ |
1:object,2:object |
100%% sure about %@ |
1:object |
%d likes |
1:int |
Compatibility (same signature ⇒ compatible):
| Old | New | Compatible? | Why |
|---|---|---|---|
Hello %@ |
Hi %@ |
✅ | text-only change |
%1$@ said %2$@ |
%2$@ told by %1$@ |
✅ | positional reorder, same types |
%d likes |
%@ likes |
❌ | int → object |
%1$d in %2$@ |
%1$d only |
❌ | dropped a placeholder |
Parsing the strings files
iOS .strings are old-style property lists. The WPiOS reference parses them with plutil -convert json (most robust — handles escapes, comments, encodings). Important for a cross-platform toolkit: plutil is macOS-only, but the toolkit's Android actions run on Linux. Keep the signature primitive pure-Ruby (portable); gate the .strings parser behind macOS, and provide a pure-Ruby .strings parser (or reuse Fastlane::Helper::Ios::L10nHelper) for portability. Android (strings.xml) needs its own parser.
Cross-platform considerations
printf placeholders are shared by iOS (%@, %1$d) and Android (%1$s, %d), so the signature primitive is platform-agnostic. Recommend the toolkit's usual split:
common/— the signature primitive + the diff.ios_*/android_*wrappers — parse the platform's file format into{ key => value }and call the common diff.
Relationship to existing toolkit actions
ios_lint_localizations/L10nLinterHelper— cross-locale (base ↔ translations), single point in time, SwiftGen-based. Complementary; this is the temporal axis. (The lightweight primitive here could later also back a SwiftGen-free re-implementation of that linter — out of scope.)an_validate_lib_strings— related Android validation.
Edge cases to cover
- Positional reorder of same-typed args → compatible.
%%literal → not a placeholder.- Mixed positional + non-positional in one string (rare/invalid) → be conservative/deterministic.
- New / removed keys → ignored.
- Duplicate keys → defer to the existing duplicate-key check (
StringsFileValidationHelper). - Empty / whitespace-only values; non-ASCII; escaped quotes/backslashes.
- Width / precision / length modifiers → ignored for type-classing.
.stringsdict/ ICU plurals → open question (different structure; likely v2).
Obtaining the previous version
The action compares old vs new base strings. WPiOS does: regenerate strings (generate_strings_file_for_glotpress skip_commit:true), snapshot the committed version via git show HEAD:<path> to a temp file, then diff. Recommend the action take two paths (pure), with an optional helper for the git-ref case.
Testing
- RSpec covering every example/edge case above (port the WPiOS fixtures).
- Pure-Ruby signature tests run anywhere; gate file-parsing tests by platform / use a pure-Ruby parser so Android/Linux CI passes.
Acceptance criteria
-
common/signature primitive (placeholder_signature,placeholders_compatible?,incompatible_placeholder_changes). - Action that fails/reports on incompatible base↔base changes, with
abort_on_violations/allow_retry. - iOS file-format wrapper; Android wrapper (or a follow-up issue).
- RSpec, CHANGELOG entry,
actions/README.mdentry. - Signature output matches the worked examples exactly.
Open questions
- Naming (
lint_localization_placeholder_changes?check_translations_placeholder_consistency?). - Strictness of type classes (
%d↔%icompatible — yes; revisit unsigned/hex). .stringsdict/ Android plurals / ICU MessageFormat support.- Portable
.stringsparser vsplutil(macOS-only) — required for cross-platform.
- 主要语言
- Ruby
- 星标
- 32
- 派生
- 7
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
wordpress-mobile/release-toolkit 的其他 Issue
-
enhancement release-toolkit
难度 4/5 3-5 天 新手友好度 52/100
wordpress-mobile/release-toolkit#756 ·
维护者通常 1 天内回复
-
bug release-toolkit ruby
难度 3/5 1-2 天 新手友好度 65/100
wordpress-mobile/release-toolkit#740 ·
维护者通常 1 天内回复
-
release-toolkit
难度 5/5 一周以上 新手友好度 30/100
wordpress-mobile/release-toolkit#737 ·
维护者通常 1 天内回复
-
Make `create_release_backmerge_pull_request` support squash strategy可能重新可做 @mokagio 于 624 天前认领,目前没有进行中的 PR。 未关闭bug enhancement
wordpress-mobile/release-toolkit#637 · 1 条评论 · 已指派 3 人 ·
维护者通常 1 天内回复
-
Port automation to strip App Clip from Enterprise target to `release-toolkit`可能重新可做 @mokagio 于 655 天前认领,目前没有进行中的 PR。 未关闭release-toolkit
wordpress-mobile/release-toolkit#629 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 wordpress-mobile/release-toolkit 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
TarteelAI/quranic-universal-library#1111 ·
维护者通常 1 天内回复
-
Generated cask uses deprecated `postflight` stanza; Homebrew 7 warns on every command可能已有人在做 @k4kratik 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
sachincool/cruft#4 ·
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
auth0/ruby-auth0#840 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
riscv/riscv-unified-db#2859 ·
维护者通常 2 天内回复
-
agent-driven deployment documentation future releases nice to have
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复