Skip to content

feat(i18n): make the visitor form translatable, and stop the template rotting - #39

Merged
ph33nx merged 1 commit into
mainfrom
feat/translatable-form-strings
Aug 5, 2026
Merged

feat(i18n): make the visitor form translatable, and stop the template rotting#39
ph33nx merged 1 commit into
mainfrom
feat/translatable-form-strings

Conversation

@ph33nx

@ph33nx ph33nx commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Every form label, help string, section heading and form title was emitted as a raw PHP literal, so none of them reached gettext. They were absent from the POT and from translate.wordpress.org, which meant no language pack could translate them however complete it was. A site set to Spanish rendered an English birth-details form above a correctly translated Spanish reading.

What changed

  • bin/generate.mjs wraps visitor-facing strings in __(). TRANSLATABLE_SPEC_KEYS is one list feeding both form emitters — the long tail and the heroes build their spec arrays in separate functions, so a one-sided fix would half-apply.
  • name, type and enum stay untranslated deliberately. Enum values are posted verbatim to the API and FormRenderer derives their display text with ucwords(), so translating one would send a translated value.
  • The POT is regenerated on every release instead of being hand-maintained; npm run i18n:pot refreshes it locally.

Verification

Check Result
POT msgids 617 → 861
Birth date, Latitude, Birth details, Western birth chart now extractable, previously absent
wp i18n make-pot succeeds
Codegen idempotent across two runs

test-form-strings-translatable.php scans the emitted source rather than calling spec(): at runtime __() has already returned a plain string, so a translated build is indistinguishable from an untranslated one. It was verified to fail on the previous shape before being relied on.

Verification note

phpcs, phpstan level 8, prettier, lint:js, lint:css, generate:check, check-distignore, build:all and check:blocks pass locally. phpunit and plugin-check need wp-env, which cannot start in that environment, so CI is the gate for those two.

… rotting

Every form label, help string, section heading and form title was emitted as a
raw PHP literal, so none of them reached gettext. They were absent from the POT
and from translate.wordpress.org, which meant no language pack could translate
them however complete it was: a site in Spanish rendered an English birth
details form above a correctly translated Spanish reading.

The generator now wraps visitor-facing strings in __(). TRANSLATABLE_SPEC_KEYS
is a single list feeding BOTH form emitters, because the long tail and the
heroes build their spec arrays in separate functions and a one sided fix would
half apply. name, type and enum stay untranslated on purpose: enum values are
posted verbatim to the API, so translating one would send a translated value.

POT msgids go 617 to 861. The template is now regenerated on every release
rather than hand maintained, and npm run i18n:pot refreshes it locally.

test-form-strings-translatable.php scans the emitted source rather than calling
spec(), because at runtime __() has already returned a plain string and a
translated build is indistinguishable from an untranslated one. Verified to fail
on the previous shape before being relied on.
@ph33nx
ph33nx merged commit 4629e05 into main Aug 5, 2026
11 checks passed
@ph33nx
ph33nx deleted the feat/translatable-form-strings branch August 5, 2026 17:19
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