fix(i18n): localize SEO keywords and structured data for all 14 languages#493
fix(i18n): localize SEO keywords and structured data for all 14 languages#493
Conversation
…l2) for all 14 languages Co-authored-by: pethers <[email protected]>
…ages Co-authored-by: pethers <[email protected]>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
Updates the article generation pipeline to produce fully localized SEO metadata and structured data across all 14 supported languages, instead of emitting English-only keywords and JSON-LD fields in non-English variants.
Changes:
- Extended
ContentLabelSetandCONTENT_LABELSwith localized Twitter Card labels plus localized Schema.orgjobTitleand Organizationdescriptionstrings. - Added an SEO keyword translation table + helper to localize
generateMetadata()keyword output per language (with English fallback). - Updated the HTML article template to read Twitter/JSON-LD fields from
CONTENT_LABELS[lang]instead of hardcoded English literals.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| scripts/types/content.ts | Adds new required label fields (twitterLabel1/2, jobTitle, siteDescription) to the shared label type. |
| scripts/data-transformers.ts | Populates new labels for all languages; adds SEO keyword localization table + wires localized keywords into generateMetadata(). |
| scripts/article-template.ts | Uses localized labels for Twitter Card labels and JSON-LD jobTitle / Organization description. |
Comments suppressed due to low confidence (1)
scripts/data-transformers.ts:3189
- In the 'month-ahead' case, tags are still generated using
L(lang, 'weekAhead'), which will label month-ahead articles as “Week Ahead” (and local equivalents). If month-ahead is a distinct article type (as implied by the new localized 'month ahead' keyword), add a dedicated label key (e.g.monthAhead) toContentLabelSet/CONTENT_LABELSand use it here so the tag matches the article type.
keywords.push(kw('parliament'), kw('month ahead'), kw('calendar'), kw('outlook'));
topics.push('parliament', 'outlook');
{
const tagVal = L(lang, 'weekAhead');
tags.push(typeof tagVal === 'string' ? tagVal : '');
| const kw = (k: string): string => localizeKeyword(k, lang); | ||
|
|
||
| // Add type-specific keywords | ||
| switch (type) { | ||
| case 'week-ahead': | ||
| keywords.push('parliament', 'week ahead', 'calendar', 'events'); | ||
| keywords.push(kw('parliament'), kw('week ahead'), kw('calendar'), kw('events')); |
There was a problem hiding this comment.
Keyword localization is newly introduced via SEO_KEYWORD_TRANSLATIONS/localizeKeyword() and the kw() helper, but the existing generateMetadata tests don’t assert any non-English keyword localization behavior. Add/extend unit tests to verify at least one non-English language produces localized keywords (and that unknown keywords fall back to English) to prevent regressions in this lookup-table approach.
There was a problem hiding this comment.
Added 5 new unit tests in tests/data-transformers.test.ts (commit 701a844):
- German
committee-reportskeywords are localized (ausschuss,berichte,parlament) and no longer contain English equivalents - Japanese
propositionskeywords include政府,法律案,立法,議会 - Arabic
motionskeywords includeاقتراحات,معارضة,برلمان Riksdagremains as a proper noun across all 7 non-Latin-script languagesbreaking news→Eilmeldungin German, not the English string
All 1783 tests pass.
|
@copilot apply changes based on the comments in this thread |
…Metadata() Co-authored-by: pethers <[email protected]>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
generateMetadata()produced hardcoded English keywords ('parliament','week ahead','legislation', etc.) for all language variants. The Schema.org JSON-LDjobTitleand organizationdescriptionfields were also English-only.Changes
scripts/data-transformers.tsSEO_KEYWORD_TRANSLATIONS— lookup table mapping 27 English keyword terms to all 13 non-English languageslocalizeKeyword(keyword, lang)helper with English fallbackgenerateMetadata()— allkeywords.push()calls now go throughkw()alias;Riksdagstays as-is (proper noun)jobTitleandsiteDescriptiontranslations to all 14CONTENT_LABELSlanguage blocksscripts/types/content.tsContentLabelSetwithjobTitle: stringandsiteDescription: stringscripts/article-template.ts"jobTitle"and Organization"description"now resolve viaCONTENT_LABELS[lang]tests/data-transformers.test.tscommittee-reports, Japanesepropositions, ArabicmotionsRiksdagremains a proper noun across all non-Latin-script languagesbreaking news→Eilmeldungin German)Before (German article):
After:
topicsslugs (internal categorization) andRiksdagremain in English intentionally.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.