equal
deleted
inserted
replaced
151 * |
151 * |
152 * @param string $domain Text domain. |
152 * @param string $domain Text domain. |
153 * @param string $path Language directory path. |
153 * @param string $path Language directory path. |
154 */ |
154 */ |
155 public function set_custom_path( $domain, $path ) { |
155 public function set_custom_path( $domain, $path ) { |
|
156 // If just-in-time loading was triggered before, reset the entry so it can be tried again. |
|
157 |
|
158 if ( isset( $this->all[ $domain ] ) ) { |
|
159 $this->all[ $domain ] = array_filter( $this->all[ $domain ] ); |
|
160 } |
|
161 |
|
162 if ( empty( $this->current[ $domain ] ) ) { |
|
163 unset( $this->current[ $domain ] ); |
|
164 } |
|
165 |
156 $this->custom_paths[ $domain ] = rtrim( $path, '/' ); |
166 $this->custom_paths[ $domain ] = rtrim( $path, '/' ); |
157 } |
167 } |
158 |
168 |
159 /** |
169 /** |
160 * Retrieves translation files from the specified path. |
170 * Retrieves translation files from the specified path. |
180 * and the default glob() function becomes expensive in terms of performance. |
190 * and the default glob() function becomes expensive in terms of performance. |
181 * |
191 * |
182 * @since 6.5.0 |
192 * @since 6.5.0 |
183 * |
193 * |
184 * @param null|array $files List of translation files. Default null. |
194 * @param null|array $files List of translation files. Default null. |
185 * @param string $path The path from which translation files are being fetched. |
195 * @param string $path The path from which translation files are being fetched. |
186 **/ |
196 */ |
187 $files = apply_filters( 'pre_get_language_files_from_path', null, $path ); |
197 $files = apply_filters( 'pre_get_language_files_from_path', null, $path ); |
188 |
198 |
189 if ( null !== $files ) { |
199 if ( null !== $files ) { |
190 return $files; |
200 return $files; |
191 } |
201 } |
334 |
344 |
335 /* |
345 /* |
336 * If no path is found for the given locale and a custom path has been set |
346 * If no path is found for the given locale and a custom path has been set |
337 * using load_plugin_textdomain/load_theme_textdomain, use that one. |
347 * using load_plugin_textdomain/load_theme_textdomain, use that one. |
338 */ |
348 */ |
339 if ( 'en_US' !== $locale && isset( $this->custom_paths[ $domain ] ) ) { |
349 if ( isset( $this->custom_paths[ $domain ] ) ) { |
340 $fallback_location = rtrim( $this->custom_paths[ $domain ], '/' ) . '/'; |
350 $fallback_location = rtrim( $this->custom_paths[ $domain ], '/' ) . '/'; |
341 $this->set( $domain, $locale, $fallback_location ); |
351 $this->set( $domain, $locale, $fallback_location ); |
342 return $fallback_location; |
352 return $fallback_location; |
343 } |
353 } |
344 |
354 |