Skip to content

Commit 952f493

Browse files
committed
Cleanup and updates based on feedback
1 parent d47e867 commit 952f493

7 files changed

Lines changed: 7 additions & 150 deletions

File tree

features/makejson.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ Feature: Split PO files into JSON files.
985985
And the return code should be 0
986986
And the foo-theme/my-custom-domain-de_DE-557240f2080a0894dbd39f5c2f559bf8.json file should exist
987987

988-
Scenario: Should only proces js/min.js extensions by default
988+
Scenario: Should only process js/min.js extensions by default
989989
Given an empty foo-theme directory
990990
And a foo-theme/de_DE.po file:
991991
"""
@@ -1010,7 +1010,7 @@ Feature: Split PO files into JSON files.
10101010
msgid "Foo Theme"
10111011
msgstr "Foo Theme"
10121012
1013-
#: bar-minified.min.js:15
1013+
#: bar.min.minified.min.js:15
10141014
msgid "Foo Theme"
10151015
msgstr "Foo Theme"
10161016
@@ -1030,7 +1030,7 @@ Feature: Split PO files into JSON files.
10301030
"""
10311031
And the return code should be 0
10321032
And the foo-theme/foo-theme-de_DE-557240f2080a0894dbd39f5c2f559bf8.json file should exist
1033-
And the foo-theme/foo-theme-de_DE-da8cc4943ac0f9e5cc173c7de3f7299d.json file should exist
1033+
And the foo-theme/foo-theme-de_DE-a9c6627f5fe96185c0a0d0ddd8fa0216.json file should exist
10341034

10351035
Scenario: Allows processing custom file extensions
10361036
Given an empty foo-theme directory

foo/empty.mo

-395 Bytes
Binary file not shown.

foo/translations.mo

-395 Bytes
Binary file not shown.

src/MakeJsonCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,12 @@ protected function make_json( $source_file, $destination, $map, $domain, $extens
263263
// Find all unique sources this translation originates from.
264264
$sources = array_map(
265265
static function ( $reference ) use ( $extensions ) {
266-
$file = $reference[0];
267-
266+
$file = $reference[0];
268267
$extension = pathinfo( $file, PATHINFO_EXTENSION );
269268

270-
return in_array( $extension, $extensions, true ) ? str_replace( '.min.', '.', $file ) : null;
269+
return in_array( $extension, $extensions, true )
270+
? preg_replace( "/.min.{$extension}$/", ".{$extension}", $file )
271+
: null;
271272
},
272273
$this->reference_map( $translation->getReferences(), $map )
273274
);

tests/MakeJsonTest.php

Lines changed: 0 additions & 101 deletions
This file was deleted.

tests/data/make_json/empty.po

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/data/make_json/translations.po

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)