Skip to content

Map lg=ah/sh to base locale a/s for the readings-svc /learning call - #21

Merged
mjradwin merged 1 commit into
mainfrom
fix-learning-locale-alias
Aug 21, 2026
Merged

Map lg=ah/sh to base locale a/s for the readings-svc /learning call#21
mjradwin merged 1 commit into
mainfrom
fix-learning-locale-alias

Conversation

@mjradwin

Copy link
Copy Markdown
Member

Problem

A PDF download with a daily-learning series and lg=sh (or lg=ah) fails when the fallback fetches from readings-svc:

GET /learning?dsm=on&end=2027-10-31&lg=sh&start=2026-09-01
HTTP/1.1 400 Bad Request
{"error":"Locale 'sh' not found; did you forget to import @hebcal/locales?"}

sh/ah are hebcal-web's own "append the Hebrew name too" spellings, not real @hebcal/locales names. Their base locales are s and a, and the appended Hebrew is drawn here in the renderer (Params.AppendHebrew), not by the sidecar — so the sidecar just needs the base locale.

Fix

learningLocale in internal/repository/readings/learning.go maps aha and shs at the readings-client boundary — the only code that talks to readings-svc — and passes every other lg through unchanged.

I also audited every other path into the locale packages: all in-process rendering (model/event.go, render.go, /shabbat) routes through model.AliasLocale first, which collapses shen / ahashkenazi before any locales.LookupTranslation. The /learning sidecar was the only leak, because it needs the short base codes rather than the full locale names.

Test

TestLearningMapsTransliterationLocales asserts aha, shs, and that he/"" pass through untouched.

🤖 Generated with Claude Code

readings-svc 400s on lg=sh/lg=ah ("Locale 'sh' not found") because those
are hebcal-web's own "append the Hebrew name too" spellings, not real
@hebcal/locales names -- their base locales are "a" and "s", and the
appended Hebrew is drawn here in the renderer, not by the sidecar.
learningLocale maps ah->a and sh->s at the readings-client boundary and
passes every other lg through unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mjradwin
mjradwin merged commit d97453f into main Aug 21, 2026
2 checks passed
@mjradwin
mjradwin deleted the fix-learning-locale-alias branch August 21, 2026 17:07
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