Serve the CodyColor kit from Nova with an Italian translation - #3663
Merged
Merged
Conversation
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.
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 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, andStaticPageController::static()ignores locale entirely, so it could not be translated at all. This moves the page into the Nova-managedTrainingResourcemodel and generalises that model's existinglocale_overridescolumn 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-kitroute, but nothing replaced it — there is no seeder and notraining_resourcesrow for that slug, while/trainingstill 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:
The seeder is idempotent on the slug. Production currently has no
cody-color-kitrow (onlyeu-code-week-4-vetanddiscover-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_sectionis deliberately excluded from the generic resolver: it already has its own path inpdfLinksSectionForLocale(), which merges the English supporting-detail block and applies per-URL replacements fordiscover-digital-programme. One code path per field.Nova gets one collapsed "Translated page content" panel per locale in
config('codeweek.training_translation_locales'), defaulting toit. 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.phptemplate means three intentional differences, agreed beforehand:xlbreakpoint (max-xl:!hidden); they are now visible on mobile.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 fordiscover-digital-programme.One gap worth knowing about, left unchanged here: the base
TestCasemocks theLocalemiddleware away andphpunit.xmldoes not defineLOCALES, so no test in this repo can exercise real language switching via?lang=. These tests set the app locale directly instead.