From 82c018acee659e81bee6159af0365844905af1b6 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sat, 25 Jun 2022 15:34:57 -0700 Subject: [PATCH] Fix translation support --- Gruntfile.js | 2 +- README.md | 10 +++++++++- eth-redirect-to-latest.php | 4 ++-- inc/class-eth-redirect-to-latest-post.php | 24 ++++++++++++++++++----- languages/eth-redirect-to-latest.pot | 24 +++++++++++------------ phpcs.xml | 2 +- readme.txt | 10 +++++++++- 7 files changed, 53 insertions(+), 23 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 01e53e7..1c53157 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,7 +9,7 @@ module.exports = function( grunt ) { addtextdomain: { options: { - textdomain: 'eth_redirect_to_latest_post', + textdomain: 'eth-redirect-to-latest-post', }, update_all_domains: { options: { diff --git a/README.md b/README.md index bf41892..95b854f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Tags:** latest, latest post, redirect, redirect latest, redirect post **Requires at least:** 4.5 **Tested up to:** 6.0 -**Stable tag:** 0.3 +**Stable tag:** 0.3.1 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -28,6 +28,9 @@ Yes, using the `eth_redirect_to_latest_post_query_args` or `eth_redirect_to_late ## Changelog ## +### 0.3.1 ### +* Fix translation support. + ### 0.3 ### * Introduce filters to make redirection more flexible. * Add unit tests and conform to coding standards. @@ -40,3 +43,8 @@ Yes, using the `eth_redirect_to_latest_post_query_args` or `eth_redirect_to_late ### 0.2 ### * Initial release + +## Upgrade Notice ## + +### 0.3.1 ### +Fix translation support. diff --git a/eth-redirect-to-latest.php b/eth-redirect-to-latest.php index bfe4f39..4065ca6 100644 --- a/eth-redirect-to-latest.php +++ b/eth-redirect-to-latest.php @@ -10,9 +10,9 @@ * Plugin URI: https://ethitter.com/plugins/ * Description: Redirect a chosen slug to the whatever is currently the latest post * Author: Erick Hitter - * Version: 0.3 + * Version: 0.3.1 * Author URI: https://ethitter.com/ - * Text Domain: eth_redirect_to_latest_post + * Text Domain: eth-redirect-to-latest-post * Domain Path: /languages/ * * This program is free software; you can redistribute it and/or modify diff --git a/inc/class-eth-redirect-to-latest-post.php b/inc/class-eth-redirect-to-latest-post.php index 721ab46..e03b54a 100644 --- a/inc/class-eth-redirect-to-latest-post.php +++ b/inc/class-eth-redirect-to-latest-post.php @@ -35,14 +35,14 @@ class ETH_Redirect_To_Latest_Post { * Dummy magic method. */ public function __clone() { - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ uh?', 'eth_redirect_to_latest_post' ), '0.1' ); + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ uh?', 'eth-redirect-to-latest-post' ), '0.1' ); } /** * Dummy magic method. */ public function __wakeup() { - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ uh?', 'eth_redirect_to_latest_post' ), '0.1' ); + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ uh?', 'eth-redirect-to-latest-post' ), '0.1' ); } /** @@ -81,17 +81,31 @@ class ETH_Redirect_To_Latest_Post { * Register plugin's setup action. */ private function __construct() { + add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); add_action( 'init', array( $this, 'action_init' ) ); add_action( 'parse_request', array( $this, 'action_parse_request' ) ); add_action( 'admin_init', array( $this, 'action_admin_init' ) ); } + /** + * Load plugin translations. + * + * @return void + */ + public function load_textdomain() { + load_plugin_textdomain( + 'eth-redirect-to-latest-post', + false, + dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' + ); + } + /** * Translate plugin slug. */ public function action_init() { - $this->default_slug = __( 'latest', 'eth_redirect_to_latest_post' ); + $this->default_slug = __( 'latest', 'eth-redirect-to-latest-post' ); $_slug = get_option( $this->plugin_option_name, $this->default_slug ); @@ -236,7 +250,7 @@ class ETH_Redirect_To_Latest_Post { } // Add custom input field to permalinks screen. - add_settings_field( $this->plugin_option_name, __( '"Latest post" slug', 'eth_redirect_to_latest_post' ), array( $this, 'settings_field' ), 'permalink', 'optional' ); + add_settings_field( $this->plugin_option_name, __( '"Latest post" slug', 'eth-redirect-to-latest-post' ), array( $this, 'settings_field' ), 'permalink', 'optional' ); } /** @@ -252,7 +266,7 @@ class ETH_Redirect_To_Latest_Post { /* translators: 1. Default slug, wrapped in a <code> tag. */ esc_html__( 'Set the slug that will redirect to the latest published post. The default value is %s.', - 'eth_redirect_to_latest_post' + 'eth-redirect-to-latest-post' ), '<code style="font-style: normal;">' . esc_html( $this->default_slug ) . '</code>' ); diff --git a/languages/eth-redirect-to-latest.pot b/languages/eth-redirect-to-latest.pot index 5806211..79327e1 100644 --- a/languages/eth-redirect-to-latest.pot +++ b/languages/eth-redirect-to-latest.pot @@ -1,44 +1,44 @@ -# Copyright (C) 2020 Erick Hitter +# Copyright (C) 2022 Erick Hitter # This file is distributed under the same license as the ETH Redirect to Latest Post package. msgid "" msgstr "" -"Project-Id-Version: ETH Redirect to Latest Post 0.3\n" +"Project-Id-Version: ETH Redirect to Latest Post 0.3.1\n" "Report-Msgid-Bugs-To: " -"https://wordpress.org/support/plugin/eth-redirect-to-latest\n" -"POT-Creation-Date: 2020-03-26 15:40:36+00:00\n" +"https://wordpress.org/support/plugin/eth-redirect-to-latest-post\n" +"POT-Creation-Date: 2022-06-25 22:34:10+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2022-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" -"X-Generator: grunt-wp-i18n 0.5.4\n" -"X-Poedit-KeywordsList: " -"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" -"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" "Language: en\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Poedit-Country: United States\n" "X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: " +"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" +"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" "X-Poedit-Basepath: ../\n" "X-Poedit-SearchPath-0: .\n" "X-Poedit-Bookmarks: \n" "X-Textdomain-Support: yes\n" +"X-Generator: grunt-wp-i18n 1.0.3\n" #: inc/class-eth-redirect-to-latest-post.php:38 #: inc/class-eth-redirect-to-latest-post.php:45 msgid "Cheatin’ uh?" msgstr "" -#: inc/class-eth-redirect-to-latest-post.php:94 +#: inc/class-eth-redirect-to-latest-post.php:108 msgid "latest" msgstr "" -#: inc/class-eth-redirect-to-latest-post.php:239 +#: inc/class-eth-redirect-to-latest-post.php:253 msgid ""Latest post" slug" msgstr "" -#: inc/class-eth-redirect-to-latest-post.php:253 +#: inc/class-eth-redirect-to-latest-post.php:267 #. translators: 1. Default slug, wrapped in a <code> tag. msgid "" "Set the slug that will redirect to the latest published post. The default " diff --git a/phpcs.xml b/phpcs.xml index b3a4eba..a467742 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -39,7 +39,7 @@ <rule ref="WordPress.WP.I18n"> <properties> <!-- Value: replace the text domain used. --> - <property name="text_domain" type="array" value="eth_redirect_to_latest_post"/> + <property name="text_domain" type="array" value="eth-redirect-to-latest-post"/> </properties> </rule> <rule ref="WordPress.WhiteSpace.ControlStructureSpacing"> diff --git a/readme.txt b/readme.txt index bdfeed7..9fc5afc 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://ethitter.com/donate/ Tags: latest, latest post, redirect, redirect latest, redirect post Requires at least: 4.5 Tested up to: 6.0 -Stable tag: 0.3 +Stable tag: 0.3.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -28,6 +28,9 @@ Yes, using the `eth_redirect_to_latest_post_query_args` or `eth_redirect_to_late == Changelog == += 0.3.1 = +* Fix translation support. + = 0.3 = * Introduce filters to make redirection more flexible. * Add unit tests and conform to coding standards. @@ -40,3 +43,8 @@ Yes, using the `eth_redirect_to_latest_post_query_args` or `eth_redirect_to_late = 0.2 = * Initial release + +== Upgrade Notice == + += 0.3.1 = +Fix translation support. -- GitLab