WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/16/2018 10:23:34 PM (8 months ago)
Author:
SergeyBiryukov
Message:

I18N: Set translations for all WordPress packages scripts.

Calls wp_set_script_translations for all packages scripts that have translations. Also correctly sets the domain on the translations.

Props omarreiss, pento, ocean90.
Merges [43878] to trunk.
Fixes #45161.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r44169 r44239  
    784784        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    785785        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    786                 'wp.i18n.setLocaleData( translations.locale_data, "default" );' .
    787             '})(' . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
     786                     'translations.locale_data.messages[""].domain = "default";' .
     787                     'wp.i18n.setLocaleData( translations.locale_data.messages, "default" );' .
     788                     '})(' . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
    788789        $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
    789790
     
    801802        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    802803        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    803                      'wp.i18n.setLocaleData( translations.locale_data, "internationalized-plugin" );' .
     804                     'translations.locale_data.messages[""].domain = "internationalized-plugin";' .
     805                     'wp.i18n.setLocaleData( translations.locale_data.messages, "internationalized-plugin" );' .
    804806                     '})(' . file_get_contents( DIR_TESTDATA . '/languages/plugins/internationalized-plugin-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ) . ");\n</script>\n";
    805807        $expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js'></script>\n";
     
    818820        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    819821        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    820                      'wp.i18n.setLocaleData( translations.locale_data, "internationalized-theme" );' .
     822                     'translations.locale_data.messages[""].domain = "internationalized-theme";' .
     823                     'wp.i18n.setLocaleData( translations.locale_data.messages, "internationalized-theme" );' .
    821824                     '})(' . file_get_contents( DIR_TESTDATA . '/languages/themes/internationalized-theme-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ) . ");\n</script>\n";
    822825        $expected .= "<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js'></script>\n";
     
    835838        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    836839        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    837                      'wp.i18n.setLocaleData( translations.locale_data, "admin" );' .
     840                     'translations.locale_data.messages[""].domain = "admin";' .
     841                     'wp.i18n.setLocaleData( translations.locale_data.messages, "admin" );' .
    838842                     '})(' . file_get_contents( DIR_TESTDATA . '/languages/admin-en_US-script-handle.json' ) . ");\n</script>\n";
    839843        $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n";
     
    887891        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    888892        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    889                      'wp.i18n.setLocaleData( translations.locale_data, "default" );' .
     893                     'translations.locale_data.messages[""].domain = "default";' .
     894                     'wp.i18n.setLocaleData( translations.locale_data.messages, "default" );' .
    890895                     '})(' . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
    891896        $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
     
    906911        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    907912        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    908                      'wp.i18n.setLocaleData( translations.locale_data, "default" );' .
     913                     'translations.locale_data.messages[""].domain = "default";' .
     914                     'wp.i18n.setLocaleData( translations.locale_data.messages, "default" );' .
    909915                     '})(' . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
    910916        $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
Note: See TracChangeset for help on using the changeset viewer.