Make WordPress Core


Ignore:
Timestamp:
11/15/2018 02:36:39 PM (6 years ago)
Author:
herregroen
Message:

I18N: Fix warnings in JavaScript translations.

Fixes an undefined index PHP warning in the load_script_textdomain function and a non-interrupting JS error when registering a domain which has no translations.

Props omarreiss, ocean90, georgestephanis.
Fixes #45256.

File:
1 edited

Legend:

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

    r43878 r43898  
    864864
    865865        $expected  = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>";
    866         $expected .= "\n<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n";
     866        $expected .= "\n<script type='text/javascript'>\n(function( translations ){" .
     867                     "translations.locale_data.messages[\"\"].domain = \"admin\";" .
     868                     "wp.i18n.setLocaleData( translations.locale_data.messages, \"admin\" );" .
     869                     "})({ \"locale_data\": { \"messages\": { \"\": {} } } });\n</script>\n";
     870        $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n";
    867871
    868872        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
Note: See TracChangeset for help on using the changeset viewer.