diff --git a/features/makepot.feature b/features/makepot.feature index 59479d3..5b7bcfc 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -66,6 +66,40 @@ Feature: Generate a POT file of a WordPress project Description of the plugin """ + Scenario: Adds file references for file headers. + Given an empty foo-plugin directory + And a foo-plugin/foo-plugin.php file: + """ + getRealPath() ), 'make-pot' ); - $this->project_type = 'theme'; + $this->project_type = 'theme'; + $this->main_file_path = $file->getRealPath(); return $theme_data; } @@ -502,7 +508,8 @@ protected function get_main_file_data() { WP_CLI::log( 'Theme stylesheet detected.' ); WP_CLI::debug( sprintf( 'Theme stylesheet: %s', $file->getRealPath() . '/style.css' ), 'make-pot' ); - $this->project_type = 'theme'; + $this->project_type = 'theme'; + $this->main_file_path = $file->getRealPath(); return $theme_data; } @@ -523,7 +530,8 @@ protected function get_main_file_data() { WP_CLI::log( 'Plugin file detected.' ); WP_CLI::debug( sprintf( 'Plugin file: %s', $file->getRealPath() ), 'make-pot' ); - $this->project_type = 'plugin'; + $this->project_type = 'plugin'; + $this->main_file_path = $file->getRealPath(); return $plugin_data; } @@ -622,6 +630,12 @@ protected function extract_strings() { $translation->addExtractedComment( sprintf( '%s of the plugin', $header ) ); } + if ( $this->main_file_path && $this->location ) { + $translation->addReference( + str_replace( "$this->source/", '', $this->main_file_path ) + ); + } + $translations[] = $translation; }