Skip to content
Snippets Groups Projects
Commit 5bcab0b9 authored by dyszczo's avatar dyszczo
Browse files

remove translation initialization

parent 649909a3
No related branches found
No related tags found
1 merge request!20translations
Pipeline #9762 passed with warnings with stages
in 1 minute and 23 seconds
......@@ -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;
}
}
......@@ -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 );
......
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