diff --git a/CHANGELOG.md b/CHANGELOG.md index 03827dd0df8fac2af966bc0b36429a65bc9b70de..68b058f7668cca769b2738fa025129c31f06b811 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [3.1.0] - 2019-11-13 +### Changed +- Removed .mo file +- Translation set in composer extra section + ## [3.0.5] - 2019-09-20 ### Fixed - Fixed missing wp_create_nonce function diff --git a/composer.json b/composer.json index b025d7f2fce6f6552a845762208dce3c8275f06d..5ab9f3e522a1d5ae48397fad0eb441849ae712d3 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,13 @@ "autoload-dev": { "classmap": ["src", "tests"] }, + "extra": { + "text-domain": "wp-basic-requirements", + "translations-folder": "lang", + "po-files": { + "pl_PL": "wp-basic-requirements-pl_PL.po" + } + }, "scripts": { "phpcs": "phpcs", "phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never", diff --git a/lang/wp-basic-requirements-pl_PL.mo b/lang/wp-basic-requirements-pl_PL.mo deleted file mode 100644 index 93b469251941882eb7ff80bb52a03b48b846f2e6..0000000000000000000000000000000000000000 Binary files a/lang/wp-basic-requirements-pl_PL.mo and /dev/null differ diff --git a/src/Basic_Requirement_Checker_Factory.php b/src/Basic_Requirement_Checker_Factory.php index 5c691b679b8f52844f78e3af1d63a5ec64074689..5bc7cfdc692a8e38c5863484033ef5d964f6379a 100644 --- a/src/Basic_Requirement_Checker_Factory.php +++ b/src/Basic_Requirement_Checker_Factory.php @@ -24,8 +24,7 @@ class WPDesk_Basic_Requirement_Checker_Factory { * @return WPDesk_Requirement_Checker */ public function create_requirement_checker( $plugin_file, $plugin_name, $text_domain = null ) { - return new WPDesk_Basic_Requirement_Checker( $plugin_file, $plugin_name, - $this->initialize_translations( $text_domain ), null, null ); + return new WPDesk_Basic_Requirement_Checker( $plugin_file, $plugin_name, $text_domain, null, null ); } /** @@ -42,7 +41,7 @@ class WPDesk_Basic_Requirement_Checker_Factory { $requirements_checker = new WPDesk_Basic_Requirement_Checker_With_Update_Disable( $plugin_file, $plugin_name, - $this->initialize_translations( $text_domain ), + $text_domain, $requirements['php'], $requirements['wp'] ); @@ -68,31 +67,4 @@ class WPDesk_Basic_Requirement_Checker_Factory { return $requirements_checker; } - - /** - * Tries to initialize translations for requirement checker. If not given then default library translation is used. - * - * @param string|null $text_domain - * - * @return string - */ - private function initialize_translations( $text_domain = null ) { - if ( $text_domain === null ) { - $text_domain = self::LIBRARY_TEXT_DOMAIN; - - if ( function_exists( 'determine_locale' ) ) { - $locale = determine_locale(); - } else { // before WP 5.0 compatibility - $locale = get_locale(); - } - $locale = apply_filters( 'plugin_locale', $locale, self::LIBRARY_TEXT_DOMAIN ); - - $lang_mo_file = __DIR__ . '/../lang/' . self::LIBRARY_TEXT_DOMAIN . '-' . $locale . '.mo'; - if ( file_exists( $lang_mo_file ) ) { - load_textdomain( self::LIBRARY_TEXT_DOMAIN, $lang_mo_file ); - } - } - - return $text_domain; - } } diff --git a/tests/unit/Test_Basic_Requirement_Checker_Factory.php b/tests/unit/Test_Basic_Requirement_Checker_Factory.php index adbf8d9578ddb9e8c825983c1e9a90a661e3389e..a8ca81a5b6b40d1eb781778b4c879d8a3b9aae2b 100644 --- a/tests/unit/Test_Basic_Requirement_Checker_Factory.php +++ b/tests/unit/Test_Basic_Requirement_Checker_Factory.php @@ -24,8 +24,6 @@ class Test_Basic_Requirement_Checker_Factory extends PHPUnit\Framework\TestCase WP_Mock::wpFunction( 'get_locale' ) ->andReturn( $existing_locale ); - WP_Mock::wpFunction( 'load_textdomain' ) - ->once(); // locale pl_PL exists so it should try to load it $factory = new WPDesk_Basic_Requirement_Checker_Factory(); $checker = $factory->create_from_requirement_array( 'whatever', 'whatever', $requirements );