Skip to content

add baseline translation support for the chooser - #185

Draft
possumbilities wants to merge 25 commits into
mainfrom
chooser-translations
Draft

possumbilities wants to merge 25 commits into
mainfrom
chooser-translations

Conversation

@possumbilities

@possumbilities possumbilities commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

  • fixes: the wp cli i18n command encounters errors when trying to manipulate files #186
    • amends docker-compose.yml to mount the vocabulary-theme src directory appropriate, and sets working_dir to that directory in the wordpress-cli section
  • adds baseline transifex.yml configuration file
  • setups up new src/languages dir
  • generates initial src/languages/vocabulary-theme.pot file
  • wraps all possible interface strings in static-chooser.php (minus marking statements) for WordPress appropriate gettext string extraction via wpcli
    • if we also want to provide translations of the marking statements in their various formats then we first need to update the Chooser UX to support the ability to showcase the original english statement alongside the translated statement so that people are given the option of output. It is feasible someone might want to generate an English marking statement, but utilize the UX of the chooser itself in Spanish. For the time being this initial translation setup doesn't support the markings statements as translatable strings, once the UX is evolved in later PRs that can be opened up.
  • adds starter .po and .mo files (via Transifex) for English to test with, to the src/languages directory
  • adds dynamic <html> lang attribute to header.php
  • loads the src/languages/ files within WordPress's locale functionality, specifically targeting the chooser textdomain.
  • adds a new lang URI parameter within WordPress for setting the language via the frontend dropdown select
  • populates the frontend language select based on the available translations within the chooser textdomain
  • sets up frontend logic to allow for language selection in dropdown to load appropriate language files from .po/.mo files and output an appropriately translated page.
  • includes a failure condition so that the translation component does not appear within the UX if no translation files are present.

Technical details

  1. The source .pot file is generated from wpcli (pulled from the wrapped strings in static-chooser.php): wpcli i18n make-pot . languages/vocabulary-theme.pot --domain=chooser

  2. The file is read through Transifex via the transifex.yml config, and loaded in for manual translation within the Transifex editor, wherein an end-user can select an available language to begin a translation from the source (en)

  3. Once a translation is ready, Transifex can generate a language specific .po file, which is sync'd with GitHub via the GH Integration. The relevant <lang>.po file is added to the src/languages folder. It is important that the .po file in question not have a theme or textdomain specific prefix, as WordPress will not recognize the file otherwise. For testing purposes the en_US.po and en_US.mo files have been created (temporarily), and the strings Yes and No have been set to Yep and Nope respectively to verify correct files are loaded based on a lang URI parameter being set to ?lang=en_US

  4. Once Transifex has reached an appropriate translation threshold and fired off the integration for .po generation, it will create a relevant PR, which can be approved, and merged.

  5. wpcli can then be used to generate a corresponding .mo file: wpcli i18n make-mo languages/

  6. Logic within the theme should now allow the newly add <lang> to be selectable within the available translation dropdown, which operates by setting the lang parameter in the URI.

  7. If a valid .mo file is found to match the set lang parameter, then the appropriate language translation is loaded, otherwise it will default to the original source (en).

Tests

Screenshots

Checklist

  • I have read and understood the Developer Certificate of Origin (DCO), below, which covers the contents of this pull request (PR).
  • My pull request doesn't include code or content generated with AI (also see Avoiding generative AI development tools — Creative Commons Open Source).
  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main or master).
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated unit tests and/or test scripts for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

For the purposes of this DCO, "license" is equivalent to "license or public domain dedication," and "open source license" is equivalent to "open content license or public domain dedication."

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@possumbilities possumbilities moved this from Triage to In progress in possumbilities Aug 13, 2026
@possumbilities possumbilities changed the title add translation support for the chooser add baseline translation support for the chooser Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

the wp cli i18n command encounters errors when trying to manipulate files

1 participant