Skip to content

Commit

Permalink
make pot command: Allow .jsx files. (#160)
Browse files Browse the repository at this point in the history
make pot command: Allow .jsx files.
  • Loading branch information
swissspidy committed May 23, 2019
2 parents e52a9a6 + ba1cdfd commit af81433
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions features/makepot.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,48 @@ Feature: Generate a POT file of a WordPress project
msgid "wrong-domain"
"""

Scenario: Parse .js and .jsx files for javascript translations
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin.php file:
"""
<?php
/**
* Plugin Name: Foo Plugin
*/
"""
And a foo-plugin/foo-plugin.js file:
"""
__( 'js', 'foo-plugin' );
"""
And a foo-plugin/foo-plugin.jsx file:
"""
__( 'jsx', 'foo-plugin' );
"""
And a foo-plugin/foo-plugin.whatever file:
"""
__( 'whatever', 'foo-plugin' );
"""

When I try `wp i18n make-pot foo-plugin`
Then STDOUT should be:
"""
Plugin file detected.
Success: POT file successfully generated!
"""
And the foo-plugin/foo-plugin.pot file should exist
And the foo-plugin/foo-plugin.pot file should contain:
"""
msgid "js"
"""
And the foo-plugin/foo-plugin.pot file should contain:
"""
msgid "jsx"
"""
And the foo-plugin/foo-plugin.pot file should not contain:
"""
msgid "whatever"
"""

Scenario: Extract translator comments from JavaScript file
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin.php file:
Expand Down
2 changes: 1 addition & 1 deletion src/MakePotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ protected function extract_strings() {
[
'include' => $this->include,
'exclude' => $this->exclude,
'extensions' => [ 'js' ],
'extensions' => [ 'js', 'jsx' ],
]
);

Expand Down

0 comments on commit af81433

Please sign in to comment.