WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/08/2018 11:33:46 AM (3 years ago)
Author:
herregroen
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.
Fixes #45161.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/tests/phpunit/tests/dependencies/scripts.php

    r43859 r43878  
    778778        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    779779        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    780                 "wp.i18n.setLocaleData( translations.locale_data, \"default\" );" .
    781             "})(" . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
     780                     "translations.locale_data.messages[\"\"].domain = \"default\";" .
     781                     "wp.i18n.setLocaleData( translations.locale_data.messages, \"default\" );" .
     782                     "})(" . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
    782783        $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
    783784
     
    795796        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    796797        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    797                      "wp.i18n.setLocaleData( translations.locale_data, \"internationalized-plugin\" );" .
     798                     "translations.locale_data.messages[\"\"].domain = \"internationalized-plugin\";" .
     799                     "wp.i18n.setLocaleData( translations.locale_data.messages, \"internationalized-plugin\" );" .
    798800                     "})(" . file_get_contents( DIR_TESTDATA . '/languages/plugins/internationalized-plugin-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ) . ");\n</script>\n";
    799801        $expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js'></script>\n";
     
    812814        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    813815        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    814                      "wp.i18n.setLocaleData( translations.locale_data, \"internationalized-theme\" );" .
     816                     "translations.locale_data.messages[\"\"].domain = \"internationalized-theme\";" .
     817                     "wp.i18n.setLocaleData( translations.locale_data.messages, \"internationalized-theme\" );" .
    815818                     "})(" . file_get_contents( DIR_TESTDATA . '/languages/themes/internationalized-theme-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ) . ");\n</script>\n";
    816819        $expected .= "<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js'></script>\n";
     
    829832        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    830833        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    831                      "wp.i18n.setLocaleData( translations.locale_data, \"admin\" );" .
     834                     "translations.locale_data.messages[\"\"].domain = \"admin\";" .
     835                     "wp.i18n.setLocaleData( translations.locale_data.messages, \"admin\" );" .
    832836                     "})(" . file_get_contents( DIR_TESTDATA . '/languages/admin-en_US-script-handle.json' ) . ");\n</script>\n";
    833837        $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n";
     
    877881        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    878882        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    879                      "wp.i18n.setLocaleData( translations.locale_data, \"default\" );" .
     883                     "translations.locale_data.messages[\"\"].domain = \"default\";" .
     884                     "wp.i18n.setLocaleData( translations.locale_data.messages, \"default\" );" .
    880885                     "})(" . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
    881886        $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
     
    896901        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    897902        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
    898                      "wp.i18n.setLocaleData( translations.locale_data, \"default\" );" .
     903                     "translations.locale_data.messages[\"\"].domain = \"default\";" .
     904                     "wp.i18n.setLocaleData( translations.locale_data.messages, \"default\" );" .
    899905                     "})(" . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n";
    900906        $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n";
Note: See TracChangeset for help on using the changeset viewer.