Translate split headers and add i18n key tripwire - #146
Merged
Conversation
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}
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.
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.
What
Part A — translate splits headers
app/views/activities/_splits.html.erbhad hardcoded English text: theSplitssection title, and theElapsed/Pacetable headers (the km/mi header stays dynamic — it was already correct). Replaced with a newactivity.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 includesI18n.locale, so this change is cache-safe — no cache invalidation needed.Part B — i18n key tripwire
Added
test/i18n_keys_test.rb: scans everyapp/views/**/*.erbfile for absolute i18n keys (t("foo.bar"), as opposed to lazyt(".foo")keys that resolve per-view) and asserts each one exists in the:enlocale. 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 namecalculator.distance_formula— hint shown in Time/Distance calculator modes (same Riegel-formula text as the existingcalculator.pace_formula)calculator.age_grade_formula— hint shown in Age Grade calculator modecalculator.age_grade_levels.*(8 keys) — labels for the WMA level classification table on the Age Grading guide pagecalculator.environmental.description— hint shown in Environmental Equivalence calculator modepages.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 allThese fixes were only added to
en.yml. The app hasconfig.i18n.fallbacksconfigured to fall back to:enfor 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 failuresbundle exec rubocop— 175 files inspected, no offensesathletes_controller_test.rbasserts translated splits headers render (including a French-locale check to prove real translation, not just an:enstring leaking through),i18n_keys_test.rbis the new tripwire