Skip to content

feat(i18n): move to wicket-base text domain and add fr_CA translation #minor - #63

Open
Revenantal wants to merge 3 commits into
mainfrom
feature/translations
Open

Revenantal wants to merge 3 commits into
mainfrom
feature/translations

Conversation

@Revenantal

@Revenantal Revenantal commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Context

Wicket: none
Related PRs: industrialdev/wicket-wp-account-centre#58, industrialdev/wicket-wp-theme#19, industrialdev/wicket-wp-financial-fields#10

What

  • Moves the base plugin from the shared wicket text domain to wicket-base. If a string has no wicket-base translation, it falls back to wicket.
  • Adds languages/wicket-base.pot and a Canadian French (fr_CA) translation (.po, .mo, .l10n.php) for all 369 strings.
  • Adds a pre-commit hook that regenerates the .pot, and a PR check that fails when the .pot is out of date.

Why

Base strings were spread across foreign domains (wicket-child, sassquatch, woocommerce-memberships*, and others), had no context, and were often built from fragments. That made them hard or impossible to translate. Wicket now ships fr_CA, following the Atlas translations convention (conv.stack.translations).

How

Text domain

  • WicketWP\Language loads languages/ and falls back to the wicket domain, so existing Loco/WPML translations still apply.
  • Strings on foreign domains move to wicket-base. Real WooCommerce and Event Tickets Plus strings keep their own domains.

String cleanup

  • Short strings (1 to 3 words) get a context that names the kind of string, as the short-string context rule says.
  • Fragments become whole strings ("Go back to %s", "Related %s", "Tab %d", and others). Account widget errors are built with WicketWP\Widgets\FormErrors and the output is escaped.
  • Placeholder strings get translator comments, and plurals use real plural forms.
  • Fixes English typos and a broken <em> tag.

Tooling

  • composer setup-hooks installs the pre-commit .pot hook. The hook never blocks a commit.

Impact on existing translations

Changed or re-contexted strings no longer match existing site translations. We accepted this because client translation coverage is under 1% and fr_CA now ships with the plugin. Site-level translations (Loco, wp-content/languages) still take precedence.

- Add the shared pre-commit hook that regenerates languages/<text-domain>.pot
  from the staged files. It never blocks a commit.
- Make `composer setup-hooks` install the pre-commit hook.
- Add a PR check that fails when the committed .pot is out of date.
- Change the text domain from the shared `wicket` to `wicket-base`.
  WicketWP\Language loads languages/ and falls back to `wicket` when a string
  has no `wicket-base` translation, so existing Loco/WPML translations apply.
- Move strings off foreign domains (wicket-child, sassquatch,
  woocommerce-memberships-teams, woocommerce-memberships, and WooCommerce
  strings WooCommerce does not have). Give domainless strings wicket-base.
  Real WooCommerce and Event Tickets Plus strings keep their domains.
- Apply the short-string context rule (contexts name the kind of string).
- Account widgets: build error lines with WicketWP\Widgets\FormErrors from
  whole strings ("%1$s: %2$s", "Error: %d") and escape the output instead of
  gluing field names to messages. Use sentence case for field names.
- Replace fragments with whole strings: "Go back to %s", "Related %s",
  "Tab %d", "Can't find your %s?", "Name of the %s", "Type of %s", and the
  org search placeholder that was concatenated inside _e().
- Add translator comments to all placeholder strings; use real plurals.
- Fix English typos (display, subscription, account, required, WordPress, API,
  "Log in to Purchase Ticket") and a broken <em> tag.
- Add languages/wicket-base.pot.

Existing translations of changed or re-contexted strings stop matching;
accepted because client coverage is under 1% and Wicket ships fr_CA.
- Add wicket-base-fr_CA.po covering all 369 strings in wicket-base.pot, with
  Canadian French terminology and typography. Terms shared with the Account
  Centre, theme, and financial fields reuse their translations.
- Add the compiled .mo and WordPress 6.5+ .l10n.php files.

Site-level translations (Loco, wp-content/languages) still take precedence.

@EstebanForge EstebanForge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. The migration itself checks out.

Two items I'd fix in a follow-up (neither blocks the merge):

  1. includes/components/org-search-select.php:974 still calls _e('Search for your', 'wicket'). It's the only string left on the old domain. It never lands in wicket-base.pot, so the CI drift check and Loco can't see it. Please move it to _x('Search for your', 'label', 'wicket-base').

  2. The FormErrors::field_message() docblock says API error titles get looked up in the plugin domain. The actual call is a context-free translate($message, 'wicket-base'), and catalog entries like "can't be blank" live under msgctxt "message", so that lookup can never match and those titles stay English. Same behavior as the old code, so no regression, but other packages will copy this class. Please fix the lookup or the comment.

Thanks Adrian, nice work on the fallback design :)

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.

2 participants