From 406e562a8e32ddba30895f0e7ada40021e92973e Mon Sep 17 00:00:00 2001 From: Patrick Joyce Date: Sat, 4 Apr 2026 00:11:41 -0400 Subject: [PATCH] Allow for translations --- Makefile | 12 ++++ composer.lock | 71 ++++++++++++------- fetch-jft-plugin.php | 6 +- languages/.gitkeep | 0 languages/fetch-jft.pot | 153 ++++++++++++++++++++++++++++++++++++++++ readme.txt | 6 +- src/Dashboard.php | 48 ++++++------- src/Reading.php | 2 +- src/Widget.php | 10 +-- 9 files changed, 252 insertions(+), 56 deletions(-) create mode 100644 languages/.gitkeep create mode 100644 languages/fetch-jft.pot diff --git a/Makefile b/Makefile index fe32158..64bcf3a 100644 --- a/Makefile +++ b/Makefile @@ -41,3 +41,15 @@ mysql: ## Runs mysql cli in mysql container .PHONY: bash bash: ## Runs bash shell in wordpress container docker exec -it -w /var/www/html $(BASENAME)-wordpress-1 bash + +.PHONY: makepot +makepot: ## Generate POT translation template (requires wp-cli) + wp i18n make-pot . languages/fetch-jft.pot --domain=fetch-jft --exclude=vendor,build,dist + +.PHONY: msgfmt +msgfmt: ## Compile all .po files in languages/ to .mo binaries + @for po in languages/*.po; do \ + mo="$${po%.po}.mo"; \ + echo "Compiling $$po -> $$mo"; \ + msgfmt -o "$$mo" "$$po"; \ + done diff --git a/composer.lock b/composer.lock index b57990a..800f61d 100644 --- a/composer.lock +++ b/composer.lock @@ -9,16 +9,16 @@ "packages-dev": [ { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.13.5", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4", + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4", "shasum": "" }, "require": { @@ -28,18 +28,13 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -47,29 +42,57 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-11-04T16:30:35+00:00" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.9.0" } diff --git a/fetch-jft-plugin.php b/fetch-jft-plugin.php index 8612f11..db4078d 100644 --- a/fetch-jft-plugin.php +++ b/fetch-jft-plugin.php @@ -7,10 +7,12 @@ * Install: Drop this directory into the "wp-content/plugins/" directory and activate it. * Contributors: pjaudiomv, bmltenabled * Authors: bmltenabled - * Version: 1.9.1 + * Version: 1.9.2 * Requires PHP: 7.3 * License: GPL v2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html + * Text Domain: fetch-jft + * Domain Path: /languages */ namespace Jft; @@ -37,6 +39,8 @@ public function __construct() public function pluginSetup() { + load_plugin_textdomain('fetch-jft', false, dirname(plugin_basename(__FILE__)) . '/languages'); + if (is_admin()) { add_action('admin_menu', [$this, 'optionsMenu']); } else { diff --git a/languages/.gitkeep b/languages/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/languages/fetch-jft.pot b/languages/fetch-jft.pot new file mode 100644 index 0000000..d7f52de --- /dev/null +++ b/languages/fetch-jft.pot @@ -0,0 +1,153 @@ +# Copyright (C) 2026 +# This file is distributed under the GPL v2 or later. +msgid "" +msgstr "" +"Project-Id-Version: Fetch JFT 1.9.1\n" +"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/fetch-jft\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-04-04T04:08:53+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"X-Generator: WP-CLI 2.12.0\n" +"X-Domain: fetch-jft\n" + +#. Plugin Name of the plugin +#: fetch-jft-plugin.php +#: src/Dashboard.php:54 +#: src/Widget.php:13 +msgid "Fetch JFT" +msgstr "" + +#. Plugin URI of the plugin +#: fetch-jft-plugin.php +msgid "https://wordpress.org/plugins/fetch-jft/" +msgstr "" + +#. Description of the plugin +#: fetch-jft-plugin.php +msgid "This is a plugin that fetches the Just For Today from NAWS and puts it on your site Simply add [jft] shortcode to your page. Fetch JFT Widget can be added to your sidebar or footer as well." +msgstr "" + +#: src/Dashboard.php:53 +#: src/Dashboard.php:86 +msgid "Fetch JFT Plugin Settings" +msgstr "" + +#: src/Dashboard.php:65 +msgid "Settings" +msgstr "" + +#: src/Dashboard.php:109 +msgid "Language" +msgstr "" + +#: src/Dashboard.php:117 +msgid "Danish" +msgstr "" + +#: src/Dashboard.php:118 +msgid "English" +msgstr "" + +#: src/Dashboard.php:119 +msgid "Farsi" +msgstr "" + +#: src/Dashboard.php:120 +msgid "French" +msgstr "" + +#: src/Dashboard.php:121 +msgid "German" +msgstr "" + +#: src/Dashboard.php:122 +msgid "Italian" +msgstr "" + +#: src/Dashboard.php:123 +msgid "Japanese" +msgstr "" + +#: src/Dashboard.php:124 +msgid "Portuguese" +msgstr "" + +#: src/Dashboard.php:125 +msgid "Russian" +msgstr "" + +#: src/Dashboard.php:126 +msgid "Spanish" +msgstr "" + +#: src/Dashboard.php:127 +msgid "Swedish" +msgstr "" + +#: src/Dashboard.php:134 +msgid "Choose the language for the JFT Display." +msgstr "" + +#: src/Dashboard.php:134 +msgid "insert [jft] shortcode on your page or post." +msgstr "" + +#: src/Dashboard.php:134 +msgid "Languages other than English only work with raw HTML layout." +msgstr "" + +#: src/Dashboard.php:138 +msgid "Layout" +msgstr "" + +#: src/Dashboard.php:143 +msgid "Table (Raw HTML)" +msgstr "" + +#: src/Dashboard.php:146 +msgid "Block (For English)" +msgstr "" + +#: src/Dashboard.php:148 +msgid "Only for English." +msgstr "" + +#: src/Dashboard.php:148 +msgid "Change between raw HTML Table and CSS block elements." +msgstr "" + +#: src/Dashboard.php:152 +msgid "Timezone (English Only)" +msgstr "" + +#: src/Dashboard.php:156 +msgid "Server Default" +msgstr "" + +#: src/Dashboard.php:206 +msgid "Only applies when English language is selected. Leave blank to use server default." +msgstr "" + +#: src/Reading.php:29 +msgid "Fetch JFT Error" +msgstr "" + +#: src/Reading.php:29 +msgid "Block layout can only be used with English. Language set:" +msgstr "" + +#: src/Widget.php:11 +msgid "Displays the Just For Today" +msgstr "" + +#: src/Widget.php:30 +msgid "Title" +msgstr "" + +#: src/Widget.php:34 +msgid "Title:" +msgstr "" diff --git a/readme.txt b/readme.txt index a76dd94..de935a8 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: pjaudiomv, klgrimley, bmltenabled Tags: jft, just for today, narcotics anonymous, na Tested up to: 6.8 -Stable tag: 1.9.1 +Stable tag: 1.9.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -50,6 +50,10 @@ This section describes how to install the plugin and get it working. == Changelog == += 1.9.2 = + +* Added internationalization (i18n) support using WordPress text domain fetch-jft. + = 1.9.1 = * Moved Portuguese translation to NA Portugal. diff --git a/src/Dashboard.php b/src/Dashboard.php index c6b8b63..507446c 100644 --- a/src/Dashboard.php +++ b/src/Dashboard.php @@ -50,8 +50,8 @@ public function registerSettings(): void public function createMenu(string $baseFile): void { add_options_page( - esc_html__('Fetch JFT Plugin Settings'), // Page Title - esc_html__('Fetch JFT'), // Menu Title + esc_html__('Fetch JFT Plugin Settings', 'fetch-jft'), // Page Title + esc_html__('Fetch JFT', 'fetch-jft'), // Menu Title 'manage_options', // Capability 'jft-plugin', // Menu Slug [$this, 'drawSettings'] // Callback function to display the page content @@ -62,7 +62,7 @@ public function createMenu(string $baseFile): void public function settingsLink($links) { $settings_url = admin_url('options-general.php?page=jft-plugin'); - $links[] = "Settings"; + $links[] = '' . esc_html__('Settings', 'fetch-jft') . ''; return $links; } @@ -83,7 +83,7 @@ public function drawSettings(): void { ?>
-

Fetch JFT Plugin Settings

+

- Language + 'Danish', - 'english' => 'English', - 'farsi' => 'Farsi', - 'french' => 'French', - 'german' => 'German', - 'italian' => 'Italian', - 'japanese' => 'Japanese', - 'portuguese' => 'Portuguese', - 'russian' => 'Russian', - 'spanish' => 'Spanish', - 'swedish' => 'Swedish', + 'danish' => __('Danish', 'fetch-jft'), + 'english' => __('English', 'fetch-jft'), + 'farsi' => __('Farsi', 'fetch-jft'), + 'french' => __('French', 'fetch-jft'), + 'german' => __('German', 'fetch-jft'), + 'italian' => __('Italian', 'fetch-jft'), + 'japanese' => __('Japanese', 'fetch-jft'), + 'portuguese' => __('Portuguese', 'fetch-jft'), + 'russian' => __('Russian', 'fetch-jft'), + 'spanish' => __('Spanish', 'fetch-jft'), + 'swedish' => __('Swedish', 'fetch-jft'), ] ), $allowed_html ); ?> -

Choose the language for the JFT Display.
insert [jft] shortcode on your page or post. Languages other then English only works with raw HTML layout.

+


- Layout + -

Only for English. Change between raw HTML Table and CSS block elements.

+

- Timezone (English Only) + 'Server Default', + '' => __('Server Default', 'fetch-jft'), // North America 'America/New_York' => 'America/New_York', 'America/Chicago' => 'America/Chicago', @@ -203,7 +203,7 @@ public function drawSettings(): void $allowed_html ); ?> -

Only applies when English language is selected. Leave blank to use server default.

+

diff --git a/src/Reading.php b/src/Reading.php index d21cc80..70115cb 100644 --- a/src/Reading.php +++ b/src/Reading.php @@ -26,7 +26,7 @@ public function renderReading($atts = []): string $languageConfig = $this->getLanguageConfig($language, $timezone); $response = $this->getJft($languageConfig); if ($layout == "block" && $language != "english") { - return 'Fetch JFT Error - Block layout can only be used with english. Language set: ' . $language; + return '' . esc_html__('Fetch JFT Error', 'fetch-jft') . ' - ' . esc_html__('Block layout can only be used with English. Language set:', 'fetch-jft') . ' ' . esc_html($language); } return $this->getContent($layout, $response, $languageConfig); } diff --git a/src/Widget.php b/src/Widget.php index 0362726..697167e 100644 --- a/src/Widget.php +++ b/src/Widget.php @@ -7,10 +7,10 @@ class Widget extends \WP_Widget public function __construct() { $widgetOps = array( - 'classname' => 'widget', - 'description' => 'Displays the Just For Today', + 'classname' => 'widget', + 'description' => __('Displays the Just For Today', 'fetch-jft'), ); - parent::__construct('widget', 'Fetch JFT', $widgetOps); + parent::__construct('widget', __('Fetch JFT', 'fetch-jft'), $widgetOps); } public function widget($args, $instance): void @@ -27,11 +27,11 @@ public function widget($args, $instance): void public function form($instance): void { - $title = ! empty($instance['title']) ? $instance['title'] : esc_html__('Title', 'text_domain'); + $title = ! empty($instance['title']) ? $instance['title'] : esc_html__('Title', 'fetch-jft'); ?>