使WordPress成为核心

变更集49236


忽略:
时间戳:
2020年10月20日下午04:03:58(4年(之前)
作者:
海洋90
消息:

I18N:介绍WP_文本域_注册存储文本域及其语言目录路径。

以前,使用时切换到本地()所有当前加载的文本域都已卸载并添加到$110n_卸载全球的。这阻止了切换后文本域的即时加载。只有当翻译存储在WP_角度_红外。这两个问题都已解决。

  • 添加WP_文本域_注册跟踪所有插件和主题的语言目录路径。
  • 全部更新load_*_textdomain()用于存储路径的函数WP_文本域_注册.
  • 添加$可重新加载参数到卸载文本域()定义是否可以再次实时加载文本域。这由使用WP_Locale_Switcher::load_translations().
  • 延伸_load_textdomain_just_in_time()还支持带有自定义语言目录的插件和主题的文本域。
  • 修复不正确的test_plugin_translation_after_switching_locale_twice()该测试应该早一点发现这个问题。
  • 添加一个新的测试插件/主题,用自定义语言目录测试翻译的加载。
  • 不推荐现在未使用的和私有的_获取路径转换()_获取路径_翻译_从长度_ dir()功能。

Props yoavf,瑞士,dd32,ocean90。
请参见#26511.
修复#39210.

位置:
大旅行箱
文件夹:
新增19个
15已编辑

图例:

未修改
补充
已删除
  • trunk/src/wp-includes/class-wp-locale-switcher.php

    46586兰特 49236兰特  
    197197
    198198foreach($domains作为$domain){
     199//默认文本域由“load_default_textdomain()”处理。
    199200if('default'===$domain){
    200201继续;
    201202            }
    202203
    203 unload_textdomain($domain);
     204unload_textdomain($domain,是真的);
    204205获取翻译域($domain);
    205206        }
     
    219220     */
    220221私有函数change_locale($locale){
    221 //重置翻译可用性信息。
    222 _get_path_to_translation(空,真);
     222全局$wp_locale;
    223223
    224224$this->load_translations($locale);
    225225
    226         $全局['wp_locale']=新WP_Locale();
     226        $wp_位置=新WP_Locale();
    227227
    228228        /**
  • trunk/src/wp-includes/deprecated.php

    49197兰特 49236兰特  
    41354135返回is_string($value)?addslashes($value):$value;
    41364136}
     4137
     4138/**
     4139*获取翻译文件的路径,以便及时加载文本域。
     4140 *
     4141*在内部缓存检索到的结果。
     4142 *
     4143*@自4.7.0起
     4144*@已弃用5.6.0
     4145*@access私有
     4146 *
     4147*@请参阅_load_textdomain_just_in_time()
     4148 *
     4149*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     4150*@param bool$reset是否重置内部缓存。由切换到区域设置功能使用。
     4151*@return string | false翻译文件的路径,如果找不到翻译文件,则为false。
     4152 */
     4153函数get_path_to_translation($domain,$reset=false){
     4154_deprected_function(__function__,'5.6.0','WP_Textdomain_Registry');
     4155
     4156静态$available_translations=array();
     4157
     4158if(true===$reset){
     4159$available_translations=array();
     4160    }
     4161
     4162if(!isset($available_translations[$domain]){
     4163$available_translations[$domain]=_get_path_to_translation _from_lang_dir($domain);
     4164    }
     4165
     4166return$available_translations[$domain];
     4167}
     4168
     4169/**
     4170*获取当前语言环境的语言目录中的翻译文件的路径。
     4171 *
     4172*保存可用.mo文件的缓存列表以提高性能。
     4173 *
     4174*@自4.7.0起
     4175*@不推荐使用5.6.0
     4176*@access私有
     4177 *
     4178*@参见_get_path_to_translation()
     4179 *
     4180*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     4181*@return string | false翻译文件的路径,如果找不到翻译文件,则为false。
     4182 */
     4183函数get_path_to_translation_from_lang_dir($domain){
     4184_deprected_function(__function__,'5.6.0','WP_Textdomain_Registry');
     4185
     4186静态$cached_mofiles=空;
     4187
     4188if(空===$cachedmo文件){
     4189$cached_mofiles=数组();
     4190
     4191$locations=数组(
     4192WP_LANG_DIR.'/插件',
     4193WP_LANG_DIR.'/主题',
     4194        );
     4195
     4196foreach($locations作为$location){
     4197$mofiles=glob($location.'/*.mo');
     4198if($mofiles){
     4199$cached_mofiles=数组合并($cached_mofiles,$mofiles);
     4200            }
     4201        }
     4202    }
     4203
     4204$locale=确定_locale();
     4205$mofile=“{$domain}-{$locale}.mo”;
     4206
     4207$path=WP_LANG_DIR。'/插件/'$mofile;
     4208if(in_array($path,$cachedmofiles,true)){
     4209return$path;
     4210    }
     4211
     4212$path=WP_LANG_DIR。'/主题/'$mofile;
     4213if(in_array($path,$cachedmofiles,true)){
     4214return$path;
     4215    }
     4216
     4217返回false;
     4218}
  • trunk/src/wp-includes/l10n.php

    49193兰特 49236兰特  
    690690*@自1.5.0起
    691691 *
    692 *@global MO[]$110n当前加载的所有文本域的数组。
    693 *@global MO[]$l10n_unloaded再次卸载的所有文本域的数组。
     692*@global MO[]$110n当前加载的所有文本域的数组。
     693*@global MO[]$l10n_unloaded再次卸载的所有文本域的数组。
     694*@global WP_Textdomain_Registry$WP_Textdomain_Registry WordPress文本域注册表。
    694695 *
    695696*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     
    698699 */
    699700函数load_textdomain($domain,$mofile){
    700 全局$110n,$l10n已卸载;
     701全局$110n,$l10n已卸载,$wp_textdomain_registry;
    701702
    702703$l10n_unloaded=(数组)$l10n _ unloaded;
     
    756757$110n[$domain]=&$mo;
    757758
     759/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     760$wp_textdomain_registry->集合($domain,目录名($mofile));
     761
    758762返回true;
    759763}
     
    763767 *
    764768*@自3.0.0起
     769*@since 5.6.0添加了`$reloadable`参数。
    765770 *
    766771*@global MO[]$110n当前加载的所有文本域的数组。
    767772*@global MO[]$l10n_unloaded再次卸载的所有文本域的数组。
    768773 *
    769 *@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     774*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     775*@param bool$reloadable是否可以立即再次加载文本域。
    770776*@return bool是否卸载了textdomain。
    771777 */
    772 函数unload_textdomain($domain) {
     778函数unload_textdomain($domain,$reloadable=false) {
    773779全局$10n,$l10n_unloaded;
    774780
     
    779785*
    780786*@自3.0.0起
    781      *
    782 *@param bool$override是否覆盖文本域卸载。默认为false。
    783 *@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
    784      */
    785 $plugin_override=apply_filters('override_unload_textdomain',false,$domain);
     787*@since 5.6.0添加了`$reloadable`参数。
     788     *
     789*@param bool$override是否覆盖文本域卸载。默认为false。
     790*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     791*@param bool$reloadable是否可以立即再次加载文本域。
     792     */
     793$plugin_override=apply_filters('override_unload_textdomain',false,$domain,$reloadable);
    786794
    787795if($plugin_override){
    788 $l10n_unloaded[$domain]=true;
     796if(!$可重载){
     797$l10n_unloaded[$domain]=true;
     798        }
    789799
    790800返回true;
     
    795805     *
    796806*@自3.0.0起
    797      *
    798 *@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
    799      */
    800 do_action('unload_textdomain',$domain);
     807*@since 5.6.0添加了`$reloadable`参数。
     808     *
     809*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     810*@param bool$reloadable是否可以再次及时加载文本域。
     811     */
     812do_action('unload_textdomain',$domain,$reloadable);
    801813
    802814if(isset($110n[$domain]){
    803815取消设置($110n[$domain]);
    804816
    805 $l10n_unloaded[$domain]=true;
     817if(!$可重载){
     818$l10n_unloaded[$domain]=true;
     819        }
    806820
    807821返回true;
     
    868882 */
    869883函数load_plugin_textdomain($domain,$deprecated=false,$plugin_rel_path=false){
     884全局$wp_textdomain_registry;
     885
    870886    /**
    871887*过滤插件的区域设置。
     
    894910    }
    895911
     912/*@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     913$wp_textdomain_registry->集合($domain,$path);
     914
    896915return load_textdomain($domain,$path.'/'.$mofile);
    897916}
     
    902921*@自3.0.0起
    903922*@自4.6.0起该函数现在尝试首先从languages目录加载.mo文件。
     923 *
     924*@global WP_Textdomain_Registry$WP_Textdomain_Registry WordPress文本域注册表。
    904925 *
    905926*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     
    909930 */
    910931函数load_mulugin_textdomain($domain,$mu_plugin_rel_path=“”){
     932全局$wp_textdomain_registry;
     933
    911934/**此过滤器记录在wp-includes/l10n.php中*/
    912935$locale=应用过滤器('plugin_locale',determine_locale(),$domain);
     
    921944$path=WPMU_PLUGIN_DIR.'/'。ltrim($mu_plugin_rel_path,'/');
    922945
     946/*@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     947$wp_textdomain_registry->集合($domain,$path);
     948
    923949return load_textdomain($domain,$path.'/'.$mofile);
    924950}
     
    934960*@自1.5.0起
    935961*@自4.6.0起该函数现在尝试首先从languages目录加载.mo文件。
     962 *
     963*@global WP_Textdomain_Registry$WP_Textdomain_Registry WordPress文本域注册表。
    936964 *
    937965*@param string$domain文本域。用于检索翻译字符串的唯一标识符。
     
    941969 */
    942970函数load_theme_textdomain($domain,$path=false){
     971全局$wp_textdomain_registry;
     972
    943973    /**
    944974*过滤主题的区域设置。
     
    961991$path=获取模板目录();
    962992    }
     993
     994/*@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     995$wp_textdomain_registry->集合($domain,$path);
    963996
    964997return load_textdomain($domain,$path.'/'.$locale.'.mo');
     
    11911224*@access私有
    11921225 *
    1193  * @请参见get_translations_for_domain()
    1194 *@全球MO[]$l10n_unloaded再次卸载的所有文本域的数组.
     1226 * @global MO[]$l10n_unloaded再次卸载的所有文本域的数组。
     1227*@全球WP_Textdomain_Registry$WP_Textdomain_Registry WordPress文本域注册表.
    11951228 *
    11961229*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     
    11981231 */
    11991232函数加载文本域调整输入时间($domain){
    1200 全局$110n_已卸载;
     1233全局$110n_已卸载,$wp_textdomain_registry;
    12011234
    12021235$l10n_unloaded=(数组)$l10n _ unloaded;
     
    12071240    }
    12081241
    1209 $translation_path=_get_path_to_translation($domain);
    1210 if(false===$translation_path){
     1242/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     1243$path=$wp_textdomain_registry->get($domain);
     1244if(!$path){
    12111245返回false;
    12121246    }
    12131247
    1214 return load_textdomain($domain,$translation_path);
    1215 }
    1216 
    1217 /**
    1218 *获取翻译文件的路径,以便及时加载文本域。
    1219  *
    1220 *在内部缓存检索到的结果。
    1221  *
    1222 *@自4.7.0起
    1223 *@access私有
    1224  *
    1225 *@请参阅_load_textdomain_just_in_time()
    1226  *
    1227 *@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
    1228 *@param bool$reset是否重置内部缓存。由切换到区域设置功能使用。
    1229 *@return string | false翻译文件的路径,如果找不到翻译文件,则为false。
    1230  */
    1231 函数get_path_to_translation($domain,$reset=false){
    1232 静态$available_translations=array();
    1233 
    1234 if(true===$reset){
    1235 $available_translations=array();
    1236     }
    1237 
    1238 if(!isset($available_translations[$domain]){
    1239 $available_translations[$domain]=_get_path_to_translation _from_lang_dir($domain);
    1240     }
    1241 
    1242 return$available_translations[$domain];
    1243 }
    1244 
    1245 /**
    1246 *获取当前区域设置的语言目录中翻译文件的路径。
    1247  *
    1248 *保存可用.mo文件的缓存列表以提高性能。
    1249  *
    1250 *@自4.7.0起
    1251 *@access私有
    1252  *
    1253 *@请参见_get_path_to_translation()
    1254  *
    1255 *@param string$domain文本域。用于检索翻译字符串的唯一标识符。
    1256 *@return string | false翻译文件的路径,如果找不到翻译文件,则为false。
    1257  */
    1258 函数get_path_to_translation_from_lang_dir($domain){
    1259 静态$cached_mofiles=空;
    1260 
    1261 if(空===$cachedmo文件){
    1262 $cached_mofiles=数组();
    1263 
    1264 $locations=数组(
    1265 WP_LANG_DIR.'/插件',
    1266 WP_LANG_DIR.'/主题',
    1267         );
    1268 
    1269 foreach($locations作为$location){
    1270 $mofiles=glob($location.'/*.mo');
    1271 if($mofiles){
    1272 $cached_mofiles=数组合并($cached_mofiles,$mofiles);
    1273             }
    1274         }
    1275     }
    1276 
    12771248$locale=确定_locale();
    1278 $mofile=“{$domain}-{$locale}.mo”;
    1279 
    1280 $path=WP_LANG_DIR。'/插件/'$mofile;
    1281 if(in_array($path,$cachedmofiles,true)){
    1282 return$path;
    1283     }
    1284 
    1285 $path=WP_LANG_DIR。'/主题/'$mofile;
    1286 if(in_array($path,$cachedmofiles,true)){
    1287 return$path;返回$path;
    1288     }
    1289 
    1290 返回false;
     1249
     1250//语言目录位于WP_LANG_DIR之外的主题具有不同的文件名。
     1251$template_directory=trailingslashit(get_template_directory());
     1252$stylesheet_directory=拖尾斜线(get_stylesheet_directory());
     1253if(0==strpos($path,$template_directory)||0==strpos($path,$stylesheet_directory)){
     1254$mofile=“{$path}{$locale}.mo”;
     1255}其他{
     1256$mofile=“{$path}{$domain}-{$locale}.mo”;
     1257    }
     1258
     1259return load_textdomain($domain,$mofile);
    12911260}
    12921261
     
    12981267*@自2.8.0起
    12991268 *
    1300 *@全球MO[]110亿美元
     1269*@全球MO[]110亿美元当前加载的所有文本域的数组。
    13011270 *
    13021271*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
     
    13221291*@自3.0.0起
    13231292 *
    1324 *@全球MO[]110亿美元
     1293*@全球MO[]110亿美元当前加载的所有文本域的数组。
    13251294 *
    13261295*@param string$domain文本域。用于检索已翻译字符串的唯一标识符。
  • 中继/src/wp-settings.php

    49226兰特 49236兰特  
    153153//加载L10n库。
    154154需要一次ABSPATH。WPINC.公司/l10n.php';
     155需要一次ABSPATH。WPINC.公司/class-wp-textdomain-registry.php';
    155156需要一次ABSPATH。WPINC公司/class-wp-locale.php';
    156157需要一次ABSPATH。WPINC公司/class-wp-locale-switcher.php';
     
    302303$GLOBALS['wp_embed']=新wp_embed();
    303304
     305/**
     306*WordPress Textdomain注册表对象。
     307 *
     308*用于支持手动加载的文本域的即时翻译。
     309 *
     310*@自5.6.0起
     311 *
     312*@global WP_Locale_Switcher$WP_Locale_Switcher WordPress文本域注册表。
     313 */
     314$GLOBALS['wp_textdomain_registry']=新wp_textdomain_registry();
     315
    304316//加载多站点特定的文件。
    305317if(is_multisite()){
  • trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-de_de.po

    48930兰特 49236兰特  
    “项目Id版本:\n”
    44“POT-创建日期:2015-12-31 16:31+0100\n”
    5 “PO-修订日期:2016-10-26 00:02+0200\n“
     5“PO-修订日期:2020-10-20 17:11+0200\n“
    66“语言:de_de\n”
    77“MIME版本:1.0\n”
    88“内容类型:text/plain;字符集=UTF-8 \n”
    99“内容传输编码:8位\n”
    10 “X生成器:Poedit1.8.10\n“
     10“X生成器:Poedit第2.4.1条\n“
    1111“X-Poedit-Basepath:。\n”
    1212“复数形式:nplurals=2;复数形式=(n!=1);\n”
     
    1515“esc_html_x:1,2c\n”
    1616“X-Textdomain-Support:yes\n”
     17“语言团队:\n”
     18“最后一个转换器:\n”
    1719“X-Poedit-SearchPath-0:。\n”
    1820
  • trunk/tests/phpunit/data/languages/themes/internationalized-theme-de_de.po

    48930兰特 49236兰特  
    “项目Id版本:\n”
    44“POT-创建日期:2015-12-31 16:38+0100\n”
    5 “PO-修订日期:2016-10-26 00:02+0200\n“
     5“PO-修订日期:2020-10-20 17:09+0200\n“
    66“语言:de_de\n”
    77“MIME版本:1.0\n”
    88“内容类型:text/plain;charset=UTF-8\n”
    99“内容传输编码:8位\n”
    10 “X生成器:Poedit1.8.10\n“
     10“X生成器:Poedit第2.4.1条\n英寸
    1111“X-Poedit-Basepath:。\n”
    1212“复数形式:nplurals=2;复数形式=(n!=1);\n”
     
    1515“esc_html_x:1,2c\n”
    1616“X-Textdomain-Support:yes\n”
     17“上一个转换器:\n”
     18“语言团队:\n”
    1719“X-Poedit-SearchPath-0:。\n”
    1820
  • trunk/tests/phpunit/data/plugins/hello.php

    46586兰特 49236兰特  
    55描述:这不仅仅是一个插件,它象征着整整一代人的希望和热情,这可以用路易斯·阿姆斯特朗最著名的两个词来概括:你好,多莉。激活后,您将在每个页面的管理屏幕右上角随机看到来自Hello,Dolly的歌词。
    66作者:Matt Mullenweg
    7 版本:1。5.1
     7版本:1。7.2
    88作者URI:网址:http://ma.tt/
    99文本域:hello dolly
    1010
    1111*/
    12 
    13 //测试
    14 ?>
  • trunk/tests/phpunit/includes/bootstrap.php

    49226兰特 49236兰特  
    7777define('DIR_TESTROOT',realpath(目录名(__DIR__)));
    7878
    79 定义('WP_LANG_DIR',DIR_TESTDATA.'/languages');
     79define('WP_LANG_DIR',realpath(DIR_TESTDATA.'/languages'));
     80define('WP_PLUGIN_DIR',realpath(DIR_TESTDATA.'/plugins');
    8081
    8182if(!已定义('WP_TESTS_FORCE_NOWN_BUGS')){
  • trunk/tests/phpunit/tests/admin/includesPlugin.php

    人民币49112元 49236兰特  
    1515'作者'=>'<a href=“网址:http://ma.tt/“>Matt Mullenweg”,
    1616“AuthorURI”=>“网址:http://ma.tt/',
    17 “版本”=>“1”。5.1',
     17“版本”=>“1”。7.2',
    1818'TextDomain'=>'hello-dolly',
    1919“DomainPath”=>“”,
  • trunk/tests/phpunit/tests/l10n/loadTextdomain.php

    46586兰特 49236兰特  
    2525add_filter('plugin_locale',数组($this,'store_locale'));
    2626add_filter('theme_locale',数组($this,'store_locale'));
     27
     28/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     29全局$wp_textdomain_registry;
     30
     31$wp_textdomain_registry->重置();
    2732    }
    2833
     
    3136remove_filter('theme_locale',数组($this,'store_locale'));
    3237
     38/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     39全局$wp_textdomain_registry;
     40
     41$wp_textdomain_registry->重置();
     42
    3343父项::tearDown();
    3444    }
     
    117127*@门票21319
    118128     */
    119    函数test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations(){
     129   公众的函数测试_is_textdomain_is_not_loaded_after_getext_call_with_no_translations(){
    120130$this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
    121131__('只是一些字符串','wp-tests-domain');
     
    123133    }
    124134
    125    函数test_override_load_textdomain_noop(){
     135   公众的函数test_override_load_textdomain_noop(){
    126136add_filter('override_load_textdomain','__return_true');
    127137$load_textdomain=load_textdomain('wp-tests-domain',DIR_TESTDATA.'/不存在文件');
     
    132142    }
    133143
    134    函数test_override_load_textdomain_non_existent_mofile(){
     144   公众的函数test_override_load_textdomain_non_existent_mofile(){
    135145add_filter('override_load_textdomain',数组($this,'_override_ load_textdomain_filter'),10,3);
    136146$load_textdomain=load_textdomain('wp-tests-domain',wp_LANG_DIR.'/non-existent-file.mo');
     
    146156    }
    147157
    148    函数test_override_load_textdomain_custom_mofile(){
     158   公众的函数test_override_load_textdomain_custom_mofile(){
    149159add_filter('override_load_textdomain',数组($this,'_override_ load_textdomain_filter'),10,3);
    150160$load_textdomain=load_textdomain('wp-tests-domain',wp_LANG_DIR.'/plugins/internationalized-plugin-de_de.mo');
     
    166176*@return bool
    167177     */
    168    函数_override_load_textdomain_filter($override,$domain,$file){
     178   公众的函数_override_load_textdomain_filter($override,$domain,$file){
    169179全球1100亿美元;
    170180
  • trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php

    47200兰特 49236兰特  
    3333add_filter('template_root',数组($this,'filter_theme_root');
    3434wp_clean_themes_cache();
    35 unset($GLOBALS['wp_themes']);
    36 取消设置($GLOBALS['l0n']);
    37 取消设置($GLOBALS['l0n_unloaded']);
    38 _get_path_to_translation(空,真);
     35未设置($GLOBALS['wp_themes'],$GLOBAS['l0n'],$GLOBALS['l10n_unloaded']);
     36
     37/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     38全局$wp_textdomain_registry;
     39
     40$wp_textdomain_registry->重置();
    3941    }
    4042
     
    4547remove_filter('template_root',数组($this,'filter_theme_root'));
    4648wp_clean_themes_cache();
    47 unset($GLOBALS['wp_themes']);
    48 取消设置($GLOBALS['l0n']);
    49 未设置($GLOBALS['l10n_unloaded']);
    50 _get_path_to_translation(空,真);
     49未设置($GLOBALS['wp_themes']、$GLOBALS['l10n']、$GLOBALS['l10n_unloaded']);
     50
     51/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     52全局$wp_textdomain_registry;
     53
     54$wp_textdomain_registry->重置();
    5155
    5256父项::tearDown();
     
    171175    /**
    172176*@门票37997
     177*@票39210
    173178     */
    174179公共函数test_plugin_translation_after_switching_locale_twice(){
     
    184189
    185190$this->assertSame(“Das ist ein Dummy Plugin”,$expected_de_de);
    186 $this->资产相同('这是一个虚拟插件',$expected_es_es);
     191$this->资产相同('Este es un-plugin虚拟',$expected_es_es);
    187192    }
    188193
  • trunk/tests/phpunit/tests/l10n/localeSwitcher.php

    48939兰特 49236兰特  
    2323$this->previous_locale='';
    2424
    25 取消设置($GLOBALS['l0n']);
    26 取消设置($GLOBALS['l0n_unloaded']);
    27 _get_path_to_translation(空,真);
     25取消设置($GLOBALS['l0n'],$GLOBAS['l10n_unloaded']);
     26
     27/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     28全局$wp_textdomain_registry;
     29
     30$wp_textdomain_registry->重置();
    2831    }
    2932
    3033公共函数tearDown(){
    31 取消设置($GLOBALS['l0n']);
    32 未设置($GLOBALS['l10n_unloaded']);
    33 _get_path_to_translation(空,真);
     34取消设置($GLOBALS['l0n'],$GLOBAS['l10n_unloaded']);
     35
     36/**@var WP_Textdomain_Registry$WP_Textdomain_Registry*/
     37全局$wp_textdomain_registry;
     38
     39$wp_textdomain_registry->reset();
    3440
    3541父项::tearDown();
     
    389395    }
    390396
     397    /**
     398*@票39210
     399     */
     400公共函数test_switch_reloads_plugin_translations_outside_wp_lang_dir(){
     401全局$wp_locale_switcher,$wp_textdomain_registry;
     402
     403$locale_switcher=克隆$wp_locale_skitcher;
     404
     405$wp_locale_switcher=新的wp_locale_switcher();
     406$wp_locale_switcher->init();
     407
     408需要一次DIR_TESTDATA。'/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php';
     409
     410$this->assertSame(WP_PLUGIN_DIR.'/custom-internationalized-PLUGIN/languages/',$WP_textdomain_registry->get('自定义国际化插件');
     411
     412$expected=custom_i18n_plugin_test();
     413$this->assertSame(“这是一个虚拟插件”,$expected);
     414
     415switch_to_locale(“es_es”);
     416switch_to_locale('de_de');
     417
     418$expected=custom_i18n_plugin_test();
     419$this->assertSame(“Das is ein Dummy Plugin”,$expected);
     420
     421restore_previous_locale();
     422
     423$expected=custom_i18n_plugin_test();
     424$this->assertSame(“Este es un-plugin dummy”,$expected);
     425
     426restore_current_locale();
     427
     428$wp_locale_switcher=$locale_sitcher;
     429    }
     430
     431    /**
     432*@票39210
     433     */
     434公共函数test_switch_reloads_theme_translations_outside_wp_lang_dir(){
     435全局$wp_locale_switcher,$wp_textdomain_registry;
     436
     437$locale_switcher=克隆$wp_locale_skitcher;
     438
     439$wp_locale_switcher=新的wp_locale_switcher();
     440$wp_locale_switcher->init();
     441
     442switch_theme('自定义国际化主题');
     443
     444require_once获取样式表目录()。'/functions.php';
     445
     446$this->assertSame(get_template_directory())。'/languages/',$wp_textdomain_registry->get('自定义国际化主题');
     447
     448$expected=自定义_i18n_theme_test();
     449
     450$this->assertSame(“这是一个虚拟主题”,$expected);
     451
     452switch_to_locale(“es_es”);
     453switch_to_scale(“de_de”);
     454
     455$应为=custom_i18n_theme_test();
     456$this->assertSame(“这是一个伪主题”,应为$);
     457
     458restore_previous_locale();
     459
     460$应为=custom_i18n_theme_test();
     461$this->assertSame(“Este es un tema dummy”,$expected);
     462
     463restore_current_locale();
     464
     465$wp_locale_switcher=$locale_sitcher;
     466    }
     467
    391468公共函数filter_locale(){
    392469return'es_es';
  • trunk/tests/phpunit/tests/theme/themeDir.php

    48937兰特 49236兰特  
    163163'目录中有空间的主题',
    164164“国际化主题”,
     165'自定义国际化主题',
    165166“camelCase”,
    166167“REST主题”,
注:请参见TracChangeset(跟踪变更集)获取有关使用变更集查看器的帮助。