Skip to content

Translate split headers and add i18n key tripwire - #146

Merged
0jonjo merged 3 commits into
mainfrom
feat/splits-i18n-tripwire
Aug 15, 2026
Merged

Translate split headers and add i18n key tripwire#146
0jonjo merged 3 commits into
mainfrom
feat/splits-i18n-tripwire

Conversation

@0jonjo

@0jonjo 0jonjo commented Aug 15, 2026

Copy link
Copy Markdown
Owner

What

Part A — translate splits headers

app/views/activities/_splits.html.erb had hardcoded English text: the Splits section title, and the Elapsed / Pace table headers (the km/mi header stays dynamic — it was already correct). Replaced with a new activity.splits.{title,elapsed,pace} namespace, added to all 15 locale files, translated to match each locale's existing terminology for "Pace" (activity.show.stat_pace) where applicable. The partial's fragment cache key already includes I18n.locale, so this change is cache-safe — no cache invalidation needed.

Part B — i18n key tripwire

Added test/i18n_keys_test.rb: scans every app/views/**/*.erb file for absolute i18n keys (t("foo.bar"), as opposed to lazy t(".foo") keys that resolve per-view) and asserts each one exists in the :en locale. This is the class of bug that has shipped "translation missing" to production twice.

Running the tripwire immediately caught several pre-existing broken keys — genuinely missing from en.yml, not regex false positives — which are fixed in this branch:

  • activities.form.type_run — fallback activity title when an activity has no name
  • calculator.distance_formula — hint shown in Time/Distance calculator modes (same Riegel-formula text as the existing calculator.pace_formula)
  • calculator.age_grade_formula — hint shown in Age Grade calculator mode
  • calculator.age_grade_levels.* (8 keys) — labels for the WMA level classification table on the Age Grading guide page
  • calculator.environmental.description — hint shown in Environmental Equivalence calculator mode
  • pages.terms.{links_title,links_desc,feedback_title,feedback_desc} — a "Related Policies" and "Feedback" section on the Terms of Use page that had no copy at all

These fixes were only added to en.yml. The app has config.i18n.fallbacks configured to fall back to :en for all 14 other locales, so this immediately resolves the missing-translation bug everywhere; proper translations for the 14 other locales can follow separately (not part of this fix, and out of scope for the tripwire test which only asserts against :en).

No regex refinements were needed — every string the pattern matched turned out to be a real t() call on an absolute key.

Test plan

  • bin/rails test — 504 runs, 1616 assertions, 0 failures
  • bundle exec rubocop — 175 files inspected, no offenses
  • New/updated tests: athletes_controller_test.rb asserts translated splits headers render (including a French-locale check to prove real translation, not just an :en string leaking through), i18n_keys_test.rb is the new tripwire

Add activity.splits.{title,elapsed,pace} to all 15 locales and use
them in the shared _splits partial instead of hardcoded English
("Splits", "Elapsed", "Pace"). The partial's cache key already
includes I18n.locale, so this is cache-safe.

Add test/i18n_keys_test.rb, a regression test that scans app/views
for absolute i18n keys (t("foo.bar")) and asserts each exists in the
:en locale, catching the same "translation missing" bug class that
has shipped to production twice. Running it surfaced several
pre-existing broken keys, now fixed in en.yml (other locales fall
back to en until translated):

- activities.form.type_run
- activity.splits.{title,elapsed,pace} (bug we're fixing here)
- calculator.age_grade_formula
- calculator.age_grade_levels.{active_beginner,approximate_world_record_level,intermediate,local_class,national_class,recreational,regional_class,world_class}
- calculator.distance_formula
- calculator.environmental.description
- pages.terms.{feedback_title,feedback_desc,links_title,links_desc}
Copilot AI lite review requested due to automatic review settings August 15, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

0jonjo added 2 commits August 15, 2026 07:11
main's tokenized public activity URLs (#142) landed after this branch
was written; update the one test the merge didn't already adjust to
use activity.public_token instead of activity.id.
@0jonjo
0jonjo merged commit 2dd789f into main Aug 15, 2026
5 checks passed
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.

2 participants