Skip to content

Serve the CodyColor kit from Nova with an Italian translation - #3663

Merged
bernardhanna merged 1 commit into
masterfrom
feat/cody-color-kit-italian
Sep 16, 2026
Merged

bernardhanna merged 1 commit into
masterfrom
feat/cody-color-kit-italian

Conversation

@bernardhanna

@bernardhanna bernardhanna commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

What this does

Switching the site to Italian now serves a fully translated /training/cody-color-kit, and the page becomes editable in Nova.

The page was a hardcoded blade (static/training/module-0.blade.php) on a static route, and StaticPageController::static() ignores locale entirely, so it could not be translated at all. This moves the page into the Nova-managed TrainingResource model and generalises that model's existing locale_overrides column from "PDF links only" to every text field.

Heads up: this also fixes a 404 already queued on master

Commit bb2b103c ("Replace the hardcoded certificate admin email with an env allowlist") removed the static /training/cody-color-kit route, but nothing replaced it — there is no seeder and no training_resources row for that slug, while /training still links to the page. Production is currently 8 commits behind master, so the page still works there. Deploying master without this PR would 404 that page. This PR supplies the missing database row and removes the now-dead blade and the duplicate static card.

Deploy steps

After merging and deploying, run on the server:

php artisan db:seed --class=TrainingResourceCodyColorKitSeeder

The seeder is idempotent on the slug. Production currently has no cody-color-kit row (only eu-code-week-4-vet and discover-digital-programme), so this creates rather than overwrites.

The five Italian PDFs are already uploaded to s3://codeweek-s3/docs/training/IT/color-kit/, named to mirror the English set, and verified publicly readable.

How translation works

TrainingResource::forLocale($field) returns the override for the active locale when present, otherwise the English attribute. Fallback is per field, so a partly finished translation degrades field by field instead of blanking the page. Trix stores an emptied editor as <div><br></div>, which is treated as empty.

pdf_links_section is deliberately excluded from the generic resolver: it already has its own path in pdfLinksSectionForLocale(), which merges the English supporting-detail block and applies per-URL replacements for discover-digital-programme. One code path per field.

Nova gets one collapsed "Translated page content" panel per locale in config('codeweek.training_translation_locales'), defaulting to it. The list is short on purpose: a panel for each of the 29 locales would put several hundred fields in one form. Adding a language later is a one-line config change. The existing "Translated PDF links" panel is untouched.

Content fidelity

The Italian copy and the Italian learning-bits graphic both come from LANDING PAGE ITALIAN - Kit CodyColor.docx. Verified programmatically rather than by eye: all 36 paragraphs of the document appear on the rendered Italian page, with no English text leaking through.

Visual changes to the English page

Moving to the shared training/show.blade.php template means three intentional differences, agreed beforehand:

  • The orange "Register activity" button now renders inside the blue callout box rather than above it.
  • The old blade hid two buttons below the xl breakpoint (max-xl:!hidden); they are now visible on mobile.
  • Styling comes from the template's prose classes rather than hand-written per-element classes, so the page is very close but not byte-identical.

Testing

Full suite passes (456 tests). Eight new tests cover the English page, the Italian page and its PDF URLs, per-field fallback for an untranslated locale, the Nova save/clear round trip, and a regression test that pdfLinksSectionForLocale() still merges the English supporting-detail block for discover-digital-programme.

One gap worth knowing about, left unchanged here: the base TestCase mocks the Locale middleware away and phpunit.xml does not define LOCALES, so no test in this repo can exercise real language switching via ?lang=. These tests set the app locale directly instead.

The CodyColor kit page was a hardcoded blade on a static route that ignored
the site language, so it could not be translated. Its static route was
already removed from master, leaving the page heading for a 404 once master
deploys: nothing served /training/cody-color-kit any more.

Move the page into the Nova-managed TrainingResource model and generalise
that model's existing locale_overrides column from PDF links only to every
text field, so switching the site to Italian serves the translated page and
the Italian PDFs. Fields left empty in a locale fall back to English one by
one, so a partly finished translation never blanks a section.

The Italian copy and the Italian learning-bits graphic come from the
translated landing page document supplied by the Italian HUB. The Italian
PDFs are already on S3 under docs/training/IT/color-kit/.

Nova gets one collapsed translation panel per language listed in
config/codeweek.php. That list is deliberately short: a panel for each of
the 29 locales would put several hundred fields in a single Nova form.
@bernardhanna
bernardhanna merged commit 7ac40da into master Sep 16, 2026
1 check failed
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