Skip to content

🐛 fix(i18n): load the plugin's own Text Domain, default and trim the Domain Path - #148

Merged
gfazioli merged 1 commit into
masterfrom
fix/text-domain-header
Nov 26, 2026
Merged

gfazioli merged 1 commit into
masterfrom
fix/text-domain-header

Conversation

@gfazioli

Copy link
Copy Markdown
Collaborator

Plugin::_init() loaded the translations with the literal 'wp-kirk', which bones rename rewrites in each plugin's vendor copy to the slug it derives from the plugin name. It only worked when that slug equals the plugin's Text Domain header: add-browser-search (wp-abs), flash-feed-scroll-reader and wp-chooseyourtheme each had to load their own catalogue. DomainPath was also read without a guard (undefined-index notice with no header) and its leading slash, which WordPress documents, was kept.

New Plugin::loadTextDomain() (called from _init(), still on init): the header's Text Domain when present, else the 'wp-kirk' literal (so a renamed copy without a header keeps working); Domain Path defaults to languages, slashes trimmed.

Proof

  • PluginTextDomainTest: 6 cases (header wins, no header, empty header, no Domain Path, empty Domain Path, leading/trailing slash); red (6 errors) before, green after. Suite 404 tests / 1114 assertions.
  • Live, .claude/scripts/textdomain-live-smoke.sh on the WordPress 7.2-RC3 folder in a local Playground, it_IT, WP_DEBUG on, debug.log empty: a copy of add-browser-search (Text Domain add-browser-search, vendor slug wp-abs, its own load_plugin_textdomain call disabled) shows "Settings" on v3.4.0 and "Impostazioni" with this branch; Scotty (Text Domain = slug) shows "Impostazioni" before and after. Scotty vendors 2.1.2, whose Plugin.php cannot be swapped for the 3.4 file, so the same change was applied in place there.

@gfazioli
gfazioli merged commit d59f401 into master Nov 26, 2026
4 checks passed
@gfazioli
gfazioli deleted the fix/text-domain-header branch November 26, 2026 12:54
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