Skip to content
Snippets Groups Projects
Commit bd96be55 authored by Dyszczo's avatar Dyszczo
Browse files

Merge branch 'feature/translations' into 'master'

translations

See merge request !20
parents 7c139690 5bcab0b9
No related branches found
No related tags found
1 merge request!20translations
Pipeline #9813 passed with stages
in 54 seconds
## [3.1.0] - 2019-11-13
### Changed
- Removed .mo file
- Translation set in composer extra section
## [3.0.5] - 2019-09-20 ## [3.0.5] - 2019-09-20
### Fixed ### Fixed
- Fixed missing wp_create_nonce function - Fixed missing wp_create_nonce function
......
...@@ -24,6 +24,13 @@ ...@@ -24,6 +24,13 @@
"autoload-dev": { "autoload-dev": {
"classmap": ["src", "tests"] "classmap": ["src", "tests"]
}, },
"extra": {
"text-domain": "wp-basic-requirements",
"translations-folder": "lang",
"po-files": {
"pl_PL": "wp-basic-requirements-pl_PL.po"
}
},
"scripts": { "scripts": {
"phpcs": "phpcs", "phpcs": "phpcs",
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never", "phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
......
File deleted
...@@ -24,8 +24,7 @@ class WPDesk_Basic_Requirement_Checker_Factory { ...@@ -24,8 +24,7 @@ class WPDesk_Basic_Requirement_Checker_Factory {
* @return WPDesk_Requirement_Checker * @return WPDesk_Requirement_Checker
*/ */
public function create_requirement_checker( $plugin_file, $plugin_name, $text_domain = null ) { public function create_requirement_checker( $plugin_file, $plugin_name, $text_domain = null ) {
return new WPDesk_Basic_Requirement_Checker( $plugin_file, $plugin_name, return new WPDesk_Basic_Requirement_Checker( $plugin_file, $plugin_name, $text_domain, null, null );
$this->initialize_translations( $text_domain ), null, null );
} }
/** /**
...@@ -42,7 +41,7 @@ class WPDesk_Basic_Requirement_Checker_Factory { ...@@ -42,7 +41,7 @@ class WPDesk_Basic_Requirement_Checker_Factory {
$requirements_checker = new WPDesk_Basic_Requirement_Checker_With_Update_Disable( $requirements_checker = new WPDesk_Basic_Requirement_Checker_With_Update_Disable(
$plugin_file, $plugin_file,
$plugin_name, $plugin_name,
$this->initialize_translations( $text_domain ), $text_domain,
$requirements['php'], $requirements['php'],
$requirements['wp'] $requirements['wp']
); );
...@@ -68,31 +67,4 @@ class WPDesk_Basic_Requirement_Checker_Factory { ...@@ -68,31 +67,4 @@ class WPDesk_Basic_Requirement_Checker_Factory {
return $requirements_checker; 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;
}
} }
...@@ -24,8 +24,6 @@ class Test_Basic_Requirement_Checker_Factory extends PHPUnit\Framework\TestCase ...@@ -24,8 +24,6 @@ class Test_Basic_Requirement_Checker_Factory extends PHPUnit\Framework\TestCase
WP_Mock::wpFunction( 'get_locale' ) WP_Mock::wpFunction( 'get_locale' )
->andReturn( $existing_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(); $factory = new WPDesk_Basic_Requirement_Checker_Factory();
$checker = $factory->create_from_requirement_array( 'whatever', 'whatever', $requirements ); $checker = $factory->create_from_requirement_array( 'whatever', 'whatever', $requirements );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment