Skip to content

feat(i18n): consume central translations from escalated-dev/locale#51

Merged
mpge merged 2 commits intomainfrom
feat/central-locale
May 2, 2026
Merged

feat(i18n): consume central translations from escalated-dev/locale#51
mpge merged 2 commits intomainfrom
feat/central-locale

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented May 2, 2026

Summary

Wires the WordPress plugin to consume translations from the new central
escalated-dev/locale
Composer package, replacing the in-tree languages/*.po files as the
canonical source of strings.

  • Adds escalated-dev/locale: ^0.1 to composer.json.
  • Refactors Escalated::boot() translation loading into a dedicated
    load_translations() method that loads two layers via WordPress'
    gettext system (later layer wins):
    1. Centralvendor/escalated-dev/locale/languages/escalated-{locale}.mo
      via load_textdomain().
    2. Local overrideslanguages/overrides/escalated-{locale}.mo
      via load_textdomain().
  • If the central package is not installed yet, falls back to the legacy
    in-tree languages/ dir via load_plugin_textdomain() so existing
    checkouts continue working until v0.1.0 is on Packagist.
  • Adds languages/overrides/.gitkeep as the override drop-in location.
  • Updates README.md with a Translations section and CHANGELOG.md.

.mo / .po assumption

WordPress' gettext implementation only loads compiled .mo files at
runtime, not .po sources. This PR assumes the central package
ships pre-compiled .mo files at:

vendor/escalated-dev/locale/languages/{textdomain}-{locale}.mo

The escalated-locale repo's CI is expected to compile .po to .mo
via msgfmt and commit/publish the compiled artifacts. If that repo
ends up shipping JSON instead of .mo, this plugin will need a small
JSON-to-gettext bridge (MO::import_from_reader or equivalent) — track
that as a follow-up.

Status

Blocked on escalated-dev/escalated-locale v0.1.0 Packagist publish.

CI will fail at composer install because escalated-dev/locale ^0.1
does not yet exist on Packagist. This is expected — the PR is marked
draft for that reason. Once v0.1.0 is published, re-run CI and lift the
draft status.

Test plan

  • After escalated-dev/locale v0.1.0 publishes to Packagist, run
    composer update escalated-dev/locale locally and verify
    vendor/escalated-dev/locale/languages/escalated-{locale}.mo
    exists.
  • On a WordPress site with WPLANG=fr_FR (or equivalent), confirm
    strings load from the central .mo (e.g. add a sentinel string
    to the central package and verify it renders).
  • Drop a custom escalated-fr_FR.mo in languages/overrides/ and
    verify its entries override the central translations for the
    same keys.
  • Remove vendor/escalated-dev/locale and confirm the plugin still
    loads translations from the legacy languages/ dir (fallback
    path).
  • CI green once the central package is published.

mpge added 2 commits May 1, 2026 22:10
Wire the WordPress plugin to load translations from the central
escalated-dev/locale Composer package, with site-level overrides
under languages/overrides/.

Layered loading (later layer wins):
  1. vendor/escalated-dev/locale/languages/escalated-{locale}.mo
  2. languages/overrides/escalated-{locale}.mo

Falls back to the legacy in-tree languages/ dir when the central
package is not installed, so existing checkouts keep working until
escalated-dev/locale v0.1.0 lands on Packagist.

Note: assumes the central package ships compiled .mo files. WordPress
gettext requires .mo at runtime; .po alone is not loadable.
Composer resolves escalated-dev/locale ^0.1 from
github.com/escalated-dev/escalated-locale via vcs repository (v0.1.1
tag). Once the package is submitted to Packagist this block can be
removed.
@mpge mpge marked this pull request as ready for review May 2, 2026 19:24
@mpge mpge merged commit cfc9c81 into main May 2, 2026
3 checks passed
@mpge mpge deleted the feat/central-locale branch May 2, 2026 19:26
mpge added a commit that referenced this pull request May 2, 2026
The plugin's textdomain loader reads from
vendor/escalated-dev/locale/languages/escalated-{locale}.mo (introduced
in #51 / cfc9c81). The release workflow built the zip from a fresh
checkout without running composer install, so vendor/ was empty and the
zip silently shipped without central translations — the plugin's
fallback to the legacy in-tree languages/ dir hid the regression at
runtime, but downstream installs miss portfolio-wide updates.

Add a setup-php + composer install step before the rsync. composer.json
itself stays excluded from the zip (end-users don't need it); only the
resolved vendor/ tree is bundled.
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