Klingon for WooCommerce
Adds Klingon (tlhIngan Hol) as a selectable language in WordPress Settings, and provides WordPress / WooCommerce translations in Klingon.
by Riaan Knoetze · github.com/riaanknoetze/klingon-for-woocommerce · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/riaanknoetze/klingon-for-woocommerce/archive/refs/heads/main.zipAdds Klingon (tlhIngan Hol) as a selectable language in WordPress, with translations for WordPress core (default, admin, and network admin domains) and WooCommerce. Coverage includes PHP, server-side templates, and JavaScript-rendered UI (Block Editor, Cart/Checkout blocks, admin React panels, etc.).
- Contributors: riaanknoetze
- Tags: klingon, language, locale, woocommerce, i18n, tlhIngan
- Requires at least: 6.4 (WP 6.5+ recommended for
.l10n.phpfast-load support) - Tested up to: 6.7
- Requires PHP: 7.4
- Stable tag: 1.0.0
- License: GPLv2 or later — https://www.gnu.org/licenses/gpl-2.0.html
Description
The plugin does three things:
- Adds Klingon to the WordPress language list. After activation, Klingon (tlhIngan Hol) appears in Settings → General → Site Language.
- Provides WordPress core translations in Klingon. Bundles full translation sets for the
default,admin, andadmin-networktext domains (~11,500 strings total) — covers most of the admin UI, Block Editor, Site Editor, and front-end translatable strings. - Provides WooCommerce translations in Klingon. Bundles
.mo,.po,.l10n.php, and per-script.jsonfiles covering cart, checkout, order statuses, billing, shipping, and more — across both PHP and JavaScript surfaces.
How it works
- On activation, all bundled translation files are mirrored into the locations WordPress checks natively. Core-domain files (
tlh.*,admin-tlh.*,admin-network-tlh.*, plus per-script.json) go intowp-content/languages/. Plugin-domain files (woocommerce-tlh.*) go intowp-content/languages/plugins/. This means translations load on the very first request — even before any runtime filter fires. - The
get_available_languagesfilter injectstlhinto every language list WordPress builds in the admin. translations_api_result,pre_set_site_transient_available_translations, andsite_transient_available_translationstogether inject the human-readable label "Klingon (tlhIngan Hol)" so the dropdown doesn't show the bare locale code. Coverage is symmetric across the cache-hit, cache-miss, and cache-write paths insidewp_get_available_translations().load_textdomain_mofileandload_translation_file(WP 6.5+) redirect translation loading to the bundled files when the site locale istlh. Both filters cover all four supported domains (default,admin,admin-network,woocommerce) uniformly. The.l10n.phpPHP-cache format is preferred over.mowhen both exist (faster load).load_script_translation_fileredirects per-script JS translations across the same domains to the bundled{prefix}{locale}-{md5}.jsonfiles. Without this, anything rendered in JavaScript (Block Editor, Site Editor, Cart/Checkout blocks, admin React panels) would stay in English even when PHP strings translate correctly.- On deactivation, the core-domain files in
wp-content/languages/are removed (so WordPress stops claiming Klingon translations exist when the plugin isn't active). Plugin-domain files inwp-content/languages/plugins/are left in place to avoid surprising the site owner during a deactivate/reactivate cycle.
Language files
| File | Domain | Purpose |
|---|---|---|
languages/tlh.{po,mo,l10n.php} |
core (default) |
WordPress front-end + general core strings |
languages/admin-tlh.{po,mo,l10n.php} |
core (admin) |
WordPress admin UI strings |
languages/admin-network-tlh.{po,mo,l10n.php} |
core (admin-network) |
Network admin (multisite) strings |
languages/woocommerce-tlh.{po,mo,l10n.php} |
woocommerce |
WooCommerce strings |
languages/tlh-{md5}.json |
core | Per-script JS translations for core (Block Editor, Site Editor, etc.) |
languages/admin-tlh-{md5}.json |
core | Per-script JS translations for admin React UI |
languages/woocommerce-tlh-{md5}.json |
woocommerce |
Per-script JS translations for Cart/Checkout blocks |
Extending or improving translations
Open languages/woocommerce-tlh.po in Poedit (free), edit the msgstr values, then use File → Compile to MO to regenerate woocommerce-tlh.mo. To regenerate the .l10n.php and per-script .json files, use WP-CLI:
wp i18n make-php languages/woocommerce-tlh.po
wp i18n make-json languages/woocommerce-tlh.po
Klingon vocabulary used in this translation:
Huch— moneyra'— order / commandleng— journey / shippingchel— addlegh— see / viewnaQ— complete / totalmI'— number / quantitynIn— goods / productmev— stop / cancel
For authoritative Klingon, consult the Klingon Language Institute.
Installation
- Upload the
klingon-localefolder to/wp-content/plugins/. - Activate the plugin through the Plugins menu in WordPress.
- Go to Settings → General and select Klingon (tlhIngan Hol) from the Site Language dropdown.
- Save Changes.
WooCommerce will now load Klingon strings automatically — both the PHP-rendered admin and the JavaScript-rendered storefront UI.
Frequently Asked Questions
Will other plugins be translated too?
WordPress core (default/admin/admin-network) and WooCommerce are bundled. Other plugins aren't — but adding them is straightforward: drop their .mo / .l10n.php / .json files into the languages/ folder, then add an entry to the PLUGIN_DOMAINS map at the top of klingon-for-woocommerce.php. The runtime filters and activation copy logic pick up new domains automatically.
The dropdown still shows "tlh" — what happened?
The translation-metadata injection runs through WordPress's available_translations site transient. If you see the bare tlh label, the transient was likely populated before the plugin loaded. Fix:
wp transient delete available_translations
Then reload Settings → General.
Why are there separate .mo, .l10n.php, and .json files?
Each format covers a different surface:
.mois the classic compiled binary used by__(),_e(), etc., in PHP..l10n.phpis a PHP-array cache introduced in WP 6.5 — same content, faster to load than parsing a.mo..jsonfiles are loaded bywp.i18nin the browser to translate strings rendered by JavaScript (Cart/Checkout blocks, admin React UI). PHP-only translations leave JS surfaces in English.
Can I use this alongside a multilingual plugin?
Yes. The plugin only sets up the locale and translation files; switching logic is left to the site owner or a multilingual plugin.
Changelog
1.0.0
- Initial release.
- Adds
tlhto the WordPress language list with the human-readable label "Klingon (tlhIngan Hol)". - Bundles WordPress core translations (
default,admin,admin-networkdomains) and WooCommerce translations in.mo,.po,.l10n.php, and per-script.jsonformats. - Hooks
load_textdomain_mofile,load_translation_file(WP 6.5+), andload_script_translation_fileto serve the bundled files at runtime across all four domains.