Changeset 44134 for trunk/src/wp-includes/l10n.php
- Timestamp:
- 12/14/2018 01:31:27 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43776
- Property svn:mergeinfo changed
-
trunk/src/wp-includes/l10n.php
r43571 r44134 103 103 $locale = $user->locale; 104 104 return $locale ? $locale : get_locale(); 105 } 106 107 /** 108 * Determine the current locale desired for the request. 109 * 110 * @since 5.0.0 111 * 112 * @global string $pagenow 113 * 114 * @return string The determined locale. 115 */ 116 function determine_locale() { 117 /** 118 * Filters the locale for the current request prior to the default determination process. 119 * 120 * Using this filter allows to override the default logic, effectively short-circuiting the function. 121 * 122 * @since 5.0.0 123 * 124 * @param string|null The locale to return and short-circuit, or null as default. 125 */ 126 $determined_locale = apply_filters( 'pre_determine_locale', null ); 127 if ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) { 128 return $determined_locale; 129 } 130 131 $determined_locale = get_locale(); 132 133 if ( is_admin() ) { 134 $determined_locale = get_user_locale(); 135 } 136 137 if ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() && is_user_logged_in() ) { 138 $determined_locale = get_user_locale(); 139 } 140 141 if ( ! empty( $_GET['wp_lang'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 142 $determined_locale = sanitize_text_field( $_GET['wp_lang'] ); 143 } 144 145 /** 146 * Filters the locale for the current request. 147 * 148 * @since 5.0.0 149 * 150 * @param string $locale The locale. 151 */ 152 return apply_filters( 'determine_locale', $determined_locale ); 105 153 } 106 154 … … 686 734 function load_default_textdomain( $locale = null ) { 687 735 if ( null === $locale ) { 688 $locale = is_admin() ? get_user_locale() : get_locale();736 $locale = determine_locale(); 689 737 } 690 738 … … 735 783 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 736 784 */ 737 $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );785 $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); 738 786 739 787 $mofile = $domain . '-' . $locale . '.mo'; … … 769 817 function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { 770 818 /** This filter is documented in wp-includes/l10n.php */ 771 $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );819 $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); 772 820 773 821 $mofile = $domain . '-' . $locale . '.mo'; … … 808 856 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 809 857 */ 810 $locale = apply_filters( 'theme_locale', is_admin() ? get_user_locale() : get_locale(), $domain );858 $locale = apply_filters( 'theme_locale', determine_locale(), $domain ); 811 859 812 860 $mofile = $domain . '-' . $locale . '.mo'; … … 942 990 } 943 991 944 $locale = is_admin() ? get_user_locale() : get_locale();992 $locale = determine_locale(); 945 993 $mofile = "{$domain}-{$locale}.mo"; 946 994
Note: See TracChangeset
for help on using the changeset viewer.