From b579598347d316a1209d33486a8b74e245f17504 Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Wed, 25 Nov 2026 20:51:33 +0100 Subject: [PATCH] Add bundled translation loading and contribution template --- README.md | 23 ++++++++ languages/markdown-alternate.pot | 93 ++++++++++++++++++++++++++++++++ markdown-alternate.php | 1 + readme.txt | 1 + src/Plugin.php | 10 ++++ 5 files changed, 128 insertions(+) create mode 100644 languages/markdown-alternate.pot diff --git a/README.md b/README.md index 5d98b08..716174a 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,29 @@ when an integration's version token still matches, so previously cached personal output is not reused. Cache duration continues to use `markdown_alternate_cache_expiration`. +### Contribute translations + +The plugin loads translations from `languages/` using the `markdown-alternate` +text domain. Create a translation from `languages/markdown-alternate.pot` in a +gettext editor, then contribute both `markdown-alternate-LOCALE.po` and its +compiled `markdown-alternate-LOCALE.mo` file, for example +`markdown-alternate-nl_NL.po` and `markdown-alternate-nl_NL.mo`. +Keep format placeholders such as `%s` and `%1$d` intact. The template alone does +not translate the plugin; a matching locale file is required. + +After changing translatable strings, regenerate the template from the repository +root with WP-CLI: + +```bash +wp i18n make-pot . languages/markdown-alternate.pot --slug=markdown-alternate --domain=markdown-alternate --exclude=vendor,tests --skip-js --headers='{"Report-Msgid-Bugs-To":"https://github.com/ProgressPlanner/markdown-alternate/issues"}' +``` + +Compile a contributed translation with: + +```bash +wp i18n make-mo languages/markdown-alternate-nl_NL.po +``` + ### Run renderer regression tests Run `php tests/run.php` after installing dependencies. These standalone tests use diff --git a/languages/markdown-alternate.pot b/languages/markdown-alternate.pot new file mode 100644 index 0000000..f0a109b --- /dev/null +++ b/languages/markdown-alternate.pot @@ -0,0 +1,93 @@ +# Copyright (C) 2026 Joost de Valk +# This file is distributed under the GPL-2.0-or-later. +msgid "" +msgstr "" +"Project-Id-Version: Markdown Alternate 1.2.0\n" +"Report-Msgid-Bugs-To: https://github.com/ProgressPlanner/markdown-alternate/issues\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"POT-Creation-Date: 2026-11-25T19:51:04+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"X-Generator: WP-CLI 2.12.0\n" +"X-Domain: markdown-alternate\n" + +#. Plugin Name of the plugin +#: markdown-alternate.php +msgid "Markdown Alternate" +msgstr "" + +#. Plugin URI of the plugin +#: markdown-alternate.php +msgid "https://github.com/ProgressPlanner/markdown-alternate" +msgstr "" + +#. Description of the plugin +#: markdown-alternate.php +msgid "Provides markdown versions of posts and pages via .md URLs" +msgstr "" + +#. Author of the plugin +#: markdown-alternate.php +msgid "Joost de Valk" +msgstr "" + +#. Author URI of the plugin +#: markdown-alternate.php +msgid "https://joost.blog" +msgstr "" + +#: src/Integration/WooCommerce.php:297 +msgid "(incl. tax)" +msgstr "" + +#: src/Integration/WooCommerce.php:299 +msgid "Price:" +msgstr "" + +#: src/Integration/WooCommerce.php:302 +#: src/Integration/WooCommerce.php:391 +msgid "SKU:" +msgstr "" + +#: src/Integration/WooCommerce.php:306 +msgid "Availability:" +msgstr "" + +#: src/Integration/WooCommerce.php:316 +msgid "Summary" +msgstr "" + +#: src/Integration/WooCommerce.php:320 +msgid "Description" +msgstr "" + +#: src/Integration/WooCommerce.php:359 +msgid "Attributes" +msgstr "" + +#. translators: %s: product attribute label, such as Size. +#: src/Integration/WooCommerce.php:378 +#, php-format +msgid "Any %s" +msgstr "" + +#: src/Integration/WooCommerce.php:395 +msgid "Variations" +msgstr "" + +#: src/Output/TermRenderer.php:251 +msgid "Subcategories" +msgstr "" + +#: src/Output/TermRenderer.php:290 +msgid "Posts" +msgstr "" + +#. translators: 1: number of posts listed, 2: total number of posts, 3: Markdown link to the HTML archive. +#: src/Output/TermRenderer.php:296 +#, php-format +msgid "Showing %1$d of %2$d. All of them: %3$s" +msgstr "" diff --git a/markdown-alternate.php b/markdown-alternate.php index 97624c8..402dfa3 100644 --- a/markdown-alternate.php +++ b/markdown-alternate.php @@ -11,6 +11,7 @@ * License: GPL-2.0-or-later * License URI: https://www.gnu.org/licenses/gpl-2.0.html * Text Domain: markdown-alternate + * Domain Path: /languages */ if (!defined('ABSPATH')) { diff --git a/readme.txt b/readme.txt index dacd83d..d8e72f6 100644 --- a/readme.txt +++ b/readme.txt @@ -103,6 +103,7 @@ Yes, as an opt-in. With `add_filter( 'markdown_alternate_skip_noindexed', '__ret == Changelog == = Unreleased = +* Added a translation template and loading support for contributed translations. * Label tax-inclusive displayed product prices and give long product descriptions their own heading. * Kept author and date archives in HTML instead of redirecting Markdown requests to missing pages * Fixed cover block images running into the first inner heading diff --git a/src/Plugin.php b/src/Plugin.php index ed64371..ea517fd 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -68,8 +68,18 @@ private function __construct() { ); add_action( 'plugins_loaded', [ $this, 'register_integrations' ] ); + add_action( 'init', array( $this, 'load_translations' ) ); } + /** + * Register bundled translations once WordPress has initialized. + * + * @return void + */ + public function load_translations(): void { + load_plugin_textdomain( 'markdown-alternate', false, dirname( plugin_basename( MARKDOWN_ALTERNATE_FILE ) ) . '/languages' ); + } + /** * Register integrations with third-party plugins. *