| 18 | |
| 19 | $this->template_wp_i18n_set_locale_data = <<<JS |
| 20 | <script type='text/javascript'> |
| 21 | (function( domain, translations ){ |
| 22 | var localeData = translations.locale_data[ domain ] || translations.locale_data.messages; |
| 23 | localeData[""].domain = domain; |
| 24 | wp.i18n.setLocaleData( localeData, domain ); |
| 25 | })( "__DOMAIN__", __JSON_TRANSLATIONS__ ); |
| 26 | </script> |
| 27 | JS; |
784 | | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>"; |
785 | | $expected .= "\n<script type='text/javascript'>\n(function( translations ){" . |
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"; |
789 | | $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n"; |
| 796 | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n"; |
| 797 | $expected .= str_replace( |
| 798 | array( |
| 799 | '__DOMAIN__', |
| 800 | '__JSON_TRANSLATIONS__', |
| 801 | ), |
| 802 | array( |
| 803 | 'default', |
| 804 | file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ), |
| 805 | ), |
| 806 | $this->template_wp_i18n_set_locale_data |
| 807 | ); |
| 808 | $expected .= "\n<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n"; |
802 | | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>"; |
803 | | $expected .= "\n<script type='text/javascript'>\n(function( translations ){" . |
804 | | 'translations.locale_data.messages[""].domain = "internationalized-plugin";' . |
805 | | 'wp.i18n.setLocaleData( translations.locale_data.messages, "internationalized-plugin" );' . |
806 | | '})(' . file_get_contents( DIR_TESTDATA . '/languages/plugins/internationalized-plugin-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ) . ");\n</script>\n"; |
807 | | $expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js'></script>\n"; |
| 821 | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n"; |
| 822 | $expected .= str_replace( |
| 823 | array( |
| 824 | '__DOMAIN__', |
| 825 | '__JSON_TRANSLATIONS__', |
| 826 | ), |
| 827 | array( |
| 828 | 'internationalized-plugin', |
| 829 | file_get_contents( DIR_TESTDATA . '/languages/plugins/internationalized-plugin-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ), |
| 830 | ), |
| 831 | $this->template_wp_i18n_set_locale_data |
| 832 | ); |
| 833 | $expected .= "\n<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js'></script>\n"; |
820 | | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>"; |
821 | | $expected .= "\n<script type='text/javascript'>\n(function( translations ){" . |
822 | | 'translations.locale_data.messages[""].domain = "internationalized-theme";' . |
823 | | 'wp.i18n.setLocaleData( translations.locale_data.messages, "internationalized-theme" );' . |
824 | | '})(' . file_get_contents( DIR_TESTDATA . '/languages/themes/internationalized-theme-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ) . ");\n</script>\n"; |
825 | | $expected .= "<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js'></script>\n"; |
| 846 | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n"; |
| 847 | $expected .= str_replace( |
| 848 | array( |
| 849 | '__DOMAIN__', |
| 850 | '__JSON_TRANSLATIONS__', |
| 851 | ), |
| 852 | array( |
| 853 | 'internationalized-theme', |
| 854 | file_get_contents( DIR_TESTDATA . '/languages/themes/internationalized-theme-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ), |
| 855 | ), |
| 856 | $this->template_wp_i18n_set_locale_data |
| 857 | ); |
| 858 | $expected .= "\n<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js'></script>\n"; |
838 | | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>"; |
839 | | $expected .= "\n<script type='text/javascript'>\n(function( translations ){" . |
840 | | 'translations.locale_data.messages[""].domain = "admin";' . |
841 | | 'wp.i18n.setLocaleData( translations.locale_data.messages, "admin" );' . |
842 | | '})(' . file_get_contents( DIR_TESTDATA . '/languages/admin-en_US-script-handle.json' ) . ");\n</script>\n"; |
843 | | $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n"; |
| 871 | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n"; |
| 872 | $expected .= str_replace( |
| 873 | array( |
| 874 | '__DOMAIN__', |
| 875 | '__JSON_TRANSLATIONS__', |
| 876 | ), |
| 877 | array( |
| 878 | 'admin', |
| 879 | file_get_contents( DIR_TESTDATA . '/languages/admin-en_US-script-handle.json' ), |
| 880 | ), |
| 881 | $this->template_wp_i18n_set_locale_data |
| 882 | ); |
| 883 | $expected .= "\n<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n"; |
871 | | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>"; |
872 | | $expected .= "\n<script type='text/javascript'>\n(function( translations ){" . |
873 | | 'translations.locale_data.messages[""].domain = "admin";' . |
874 | | 'wp.i18n.setLocaleData( translations.locale_data.messages, "admin" );' . |
875 | | "})({ \"locale_data\": { \"messages\": { \"\": {} } } });\n</script>\n"; |
876 | | $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n"; |
| 911 | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n"; |
| 912 | $expected .= str_replace( |
| 913 | array( |
| 914 | '__DOMAIN__', |
| 915 | '__JSON_TRANSLATIONS__', |
| 916 | ), |
| 917 | array( |
| 918 | 'admin', |
| 919 | '{ "locale_data": { "messages": { "": {} } } }', |
| 920 | ), |
| 921 | $this->template_wp_i18n_set_locale_data |
| 922 | ); |
| 923 | $expected .= "\n<script type='text/javascript' src='/wp-admin/js/script.js'></script>\n"; |
891 | | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>"; |
892 | | $expected .= "\n<script type='text/javascript'>\n(function( translations ){" . |
893 | | 'translations.locale_data.messages[""].domain = "default";' . |
894 | | 'wp.i18n.setLocaleData( translations.locale_data.messages, "default" );' . |
895 | | '})(' . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n"; |
896 | | $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n"; |
| 938 | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n"; |
| 939 | $expected .= str_replace( |
| 940 | array( |
| 941 | '__DOMAIN__', |
| 942 | '__JSON_TRANSLATIONS__', |
| 943 | ), |
| 944 | array( |
| 945 | 'default', |
| 946 | file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ), |
| 947 | ), |
| 948 | $this->template_wp_i18n_set_locale_data |
| 949 | ); |
| 950 | $expected .= "\n<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n"; |
911 | | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>"; |
912 | | $expected .= "\n<script type='text/javascript'>\n(function( translations ){" . |
913 | | 'translations.locale_data.messages[""].domain = "default";' . |
914 | | 'wp.i18n.setLocaleData( translations.locale_data.messages, "default" );' . |
915 | | '})(' . file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ) . ");\n</script>\n"; |
916 | | $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n"; |
| 965 | $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js'></script>\n"; |
| 966 | $expected .= str_replace( |
| 967 | array( |
| 968 | '__DOMAIN__', |
| 969 | '__JSON_TRANSLATIONS__', |
| 970 | ), |
| 971 | array( |
| 972 | 'default', |
| 973 | file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ), |
| 974 | ), |
| 975 | $this->template_wp_i18n_set_locale_data |
| 976 | ); |
| 977 | $expected .= "\n<script type='text/javascript' src='/wp-includes/js/script.js'></script>\n"; |