WordPress.org

Making WordPress.org

Changeset 8500


Ignore:
Timestamp:
03/24/2019 08:58:17 PM (13 months ago)
Author:
ocean90
Message:

Translate: Include file reference in JSON translation files for WordPress core.

Fixes #3976.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/cli/class-export.php

    r7843 r8500  
    166166
    167167    /**
    168      * Builds a mapping of JS file names to translation entries.
     168     * Builds a a separate JSON file with translations for each JavaScript file.
    169169     *
    170170     * @param GP_Project          $gp_project The GlotPress project.
     
    176176     */
    177177    private function build_json_files( $gp_project, $gp_locale, $set, $mapping, $base_dest ) {
    178         // Export translations for each JS file to a separate translation file.
    179178        $files  = array();
    180179        $format = gp_array_get( GP::$formats, 'jed1x' );
     180
    181181        foreach ( $mapping as $file => $entries ) {
     182            // Get the translations in Jed 1.x compatible JSON format.
    182183            $json_content = $format->print_exported_file( $gp_project, $gp_locale, $set, $entries );
     184
     185            // Decode and add comment with file reference for debugging.
     186            $json_content_decoded          = json_decode( $json_content );
     187            $json_content_decoded->comment = [ 'reference' => $file ];
     188
     189            $json_content = wp_json_encode( $json_content_decoded );
    183190
    184191            $hash = md5( $file );
Note: See TracChangeset for help on using the changeset viewer.