Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script file name to JSON translation files #134

Merged
merged 2 commits into from Jan 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/makejson.feature
Expand Up @@ -119,6 +119,10 @@ Feature: Split PO files into JSON files.
"""
"generator":"WP-CLI
"""
And the foo-plugin/foo-plugin-de_DE-56746e49c6485323d16a717754b7447e.json file should contain:
"""
"source":"foo-plugin.js"
"""

Scenario: Always uses messages as text domain
Given an empty foo-plugin directory
Expand Down
1 change: 1 addition & 0 deletions src/JedGenerator.php
Expand Up @@ -31,6 +31,7 @@ public static function toString( Translations $translations, array $options = []
$data = [
'translation-revision-date' => $translations->getHeader( 'PO-Revision-Date' ),
'generator' => 'WP-CLI/' . WP_CLI_VERSION,
'source' => $options['source'],
'domain' => $domain,
'locale_data' => [
$domain => $configuration + $messages,
Expand Down
9 changes: 8 additions & 1 deletion src/MakeJsonCommand.php
Expand Up @@ -195,7 +195,14 @@ protected function build_json_files( $mapping, $base_file_name, $destination ) {
$hash = md5( $file );
$destination_file = "${destination}/{$base_file_name}-{$hash}.json";

$success = JedGenerator::toFile( $translations, $destination_file, [ 'json' => $this->json_options ] );
$success = JedGenerator::toFile(
$translations,
$destination_file,
[
'json' => $this->json_options,
'source' => $file,
]
);

if ( ! $success ) {
WP_CLI::warning( sprintf( 'Could not create file %s', basename( $destination_file, '.json' ) ) );
Expand Down