Skip to content

WEBDEV-9226: Set up string extraction and publish locale data - #129

Open
jbuckner wants to merge 5 commits into
mainfrom
WEBDEV-9226-locale-data
Open

jbuckner wants to merge 5 commits into
mainfrom
WEBDEV-9226-locale-data

Conversation

@jbuckner

@jbuckner jbuckner commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Elements' msg() calls have never been extractable, so offshoot shows them in English. This extracts them to xliff/es.xlf, translates all 37, and publishes @internetarchive/elements/locales/es.js for offshoot to merge into its one bundle (offshoot side is WEBDEV-9225, pinned to prerelease 1.1.3-webdev-9226.1).

  • The published module is lit-localize's runtime templates shape, translated messages only. An English fallback would override a real translation of the same text once it's merged.
  • Elements never calls configureLocalization. The app owns it.
  • Every element that renders a msg() is now @localized(), so a live language switch shows without a reload.
  • Seven text props (search bar placeholders/labels, scrubber label, status indicator titles) no longer default to a msg() at construction. They're unset and fall back at render, so they follow the language too.
  • ia-button drops msg(this.loadingText). Extraction needs a literal and every caller already passes a localized string.
  • README has the workflow under Localization.

WEBDEV-9226: https://webarchive.jira.com/browse/WEBDEV-9226

🤖 Generated with Claude Code

https://claude.ai/code/session_01HjwDQaR3hvZ8J2PP4117W2

jbuckner and others added 2 commits September 30, 2026 15:03
Elements had msg() calls but no lit-localize.json or localize-tools, so none
of them could be extracted and offshoot rendered them in English. This adds
extraction to xliff/es.xlf, translates all 37 strings, and publishes them as
@internetarchive/elements/locales/es.js for offshoot to merge into its bundle.

The published module is lit-localize's runtime-mode templates with one change:
scripts/build-locales.mts only writes messages that have a translation. An
English fallback would override a real translation of the same text once the
app merges it. The package never calls configureLocalization.

ia-button dropped msg(this.loadingText). Extraction needs a literal, and every
caller already passes a localized string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HjwDQaR3hvZ8J2PP4117W2
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

🚀 View preview at
https://internetarchive.github.io/elements/pr/pr-129/

Built to branch ghpages at 2026-10-01 23:46 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.26%. Comparing base (95784c8) to head (3ac331b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #129      +/-   ##
==========================================
+ Coverage   91.23%   91.26%   +0.03%     
==========================================
  Files          60       61       +1     
  Lines        2520     2529       +9     
  Branches      583      591       +8     
==========================================
+ Hits         2299     2308       +9     
  Misses         77       77              
  Partials      144      144              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jbuckner and others added 2 commits September 30, 2026 15:24
Having the translations isn't enough. Seven text properties took their default
from msg() when the element was created, so an element built before the app
loaded Spanish kept the English default. And no element re-rendered when the
language changed, so a live switch only showed after a reload.

The seven defaults (ia-scrubber-bar label, the two search bars' placeholder
and label, ia-status-indicator's three titles) are now left unset and fall
back to msg() at render. Every element that renders a msg() gets @Localized(),
including ia-transcript-entry, whose text comes from a msg() in
TranscriptEntryConfig.displayText. Diff review caught that one.

The locale test now switches elements that are already on the page, and fails
against either the old defaults or a missing @Localized().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HjwDQaR3hvZ8J2PP4117W2

@latonv latonv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice upgrade, it's great to see the localization pass finally being enabled!

Comment thread src/locales/es.ts
Comment on lines +9 to +11
export const templates = {
s061cc20e3432dead: `Pausar`,
s0661ae8e65d136c7: str`Imagen ${0} de ${1}`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Q: Do we have any process to validate/approve these translations? I don't know enough Spanish to review these myself, but a quick Claude pass over them had a few possible grammar/dialect notes that may be worth double-checking by a fluent speaker:

  • "Filtros y búsqueda avanzada disponible a continuación" should be "disponibles" — coordinated subjects take plural agreement.
  • "Search the Archive" became "Busca en el archivo", where lowercase "el archivo" reads as "the file / a generic archive" rather than the Internet Archive as a proper noun ("Busca en Internet Archive" or similar).
  • "El código que has introducido no es válido o ha caducado" is distinctly peninsular Spanish on two counts: the "tú has introducido" phrasing and the verb "introducir" itself (Latin America strongly prefers "ingresar" for entering a code). The English source is impersonal ("The code entered..."), so a neutral rendering like "El código introducido no es válido o ha caducado" would be both closer to the source and dialect-agnostic. Since the locale is generic es (not es-ES) and the Archive's audience is global, this is the most worthwhile of the extra points.

* origin/main:
  WEBDEV-9230: Make the demo page usable for QA on a phone (#127)
@latonv

latonv commented Oct 2, 2026

Copy link
Copy Markdown
Member

Note: I tried re-running build for the failed tests but it seems like there's still a failure about <ia-button-story> not rendering.

This branch has not been deployed

No deployments
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.

3 participants