Skip to content

Preserve translation text outside valid capture placeholders - #981

Open
OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/preserve-unknown-translation-placeholders
Open

OskarEichler wants to merge 1 commit into
slim-template:mainfrom
OskarEichler:codex/preserve-unknown-translation-placeholders

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Only substitute canonical positive translation capture references, and preserve out-of-range references as literal text. Static and dynamic translation should not crash or silently remove strings such as URL-encoded %20 when they do not refer to a capture.

Reproduction

With the translator plugin enabled and an identity tr_fn:

p 100%20 complete
p 100%20 complete #{"yes"}
p %0 and #{"yes"}

Before: static mode crashes on %20; dynamic mode drops it when an interpolation exists; %0 incorrectly selects the last capture. After: %20 and %0 remain literal in both modes. Existing valid %1, %2, etc. capture references continue to work.

Verification

  • Unmodified core/plugin suites: 415 runs / 650 assertions, zero failures/errors/skips on Ruby 3.2.11 and 4.0.6; existing Rails suite 15 runs / 36 assertions on each.
  • 3,200 focused checks per Ruby across static/dynamic modes, zero/one capture, normal text, zero/leading-zero/out-of-range tokens.
  • Syntax passes and no new comparative Lint offenses; no test files changed.

Compatibility / limitations

No dependency or API change. %0 and leading-zero references no longer alias real captures, and nonexistent references remain literal instead of disappearing or raising. Literal text that collides with an actual %1 reference remains ambiguous; this does not introduce a new escaping convention or change translation catalogs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant