Skip to content

Commit

Permalink
Fix incorrect directory to load text domain (#5040)
Browse files Browse the repository at this point in the history
  • Loading branch information
strategio authored and aduth committed Feb 14, 2018
1 parent 34aaa39 commit 318af95
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function gutenberg_load_plugin_textdomain() {
load_plugin_textdomain(
'gutenberg',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages/'
plugin_basename( gutenberg_dir_path() ) . '/languages/'
);
}
add_action( 'plugins_loaded', 'gutenberg_load_plugin_textdomain' );
32 changes: 32 additions & 0 deletions phpunit/class-i18n-functions-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Tests for i18n functions
*
* @package Gutenberg
*/
class I18n_Functions_Test extends WP_UnitTestCase {

/**
* @test
* @group #5038
* @covers gutenberg_load_plugin_textdomain
*/
public function it_should_load_language_files_from_gutenberg_languages() {
if ( 'gutenberg' !== plugin_basename( gutenberg_dir_path() ) ) {
$this->markTestSkipped( 'The path is not matching in docker test environment. Needs further investigation.' );
return;
}

add_action( 'load_textdomain', array( $this, 'check_arguments_in_load_textdomaincheck' ), 10, 2 );
gutenberg_load_plugin_textdomain();
}

public function check_arguments_in_load_textdomaincheck( $domain, $mofile ) {
$content_language_file_pattern = 'languages[\\/]plugins[\\/]gutenberg-[a-z]{2}_[A-Z]{2}.mo$';
$plugin_language_file_pattern = 'gutenberg[\\/]languages[\\/]gutenberg-[a-z]{2}_[A-Z]{2}.mo$';
$regex_pattern = '#' . $content_language_file_pattern . '|' . $plugin_language_file_pattern . '#';

$this->assertEquals( 'gutenberg', $domain );
$this->assertRegExp( $regex_pattern, $mofile );
}
}

0 comments on commit 318af95

Please sign in to comment.