Make WordPress Core

Changeset 58236


Ignore:
Timestamp:
05/29/2024 03:42:46 PM (4 months ago)
Author:
swissspidy
Message:

I18N: Add new lang_dir_for_domain filter.

This new filter in WP_Textdomain_Registry allows plugins to override the determined languages folder when using just-in-time translation loading.

Props swissspidy, chouby, johnbillion.
Fixes #61206.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-textdomain-registry.php

    r57831 r58236  
    8989     * @param string $locale Locale.
    9090     *
    91      * @return string|false MO file path or false if there is none available.
     91     * @return string|false Languages directory path or false if there is none available.
    9292     */
    9393    public function get( $domain, $locale ) {
    94         if ( isset( $this->all[ $domain ][ $locale ] ) ) {
    95             return $this->all[ $domain ][ $locale ];
    96         }
    97 
    98         return $this->get_path_from_lang_dir( $domain, $locale );
     94        $path = $this->all[ $domain ][ $locale ] ?? $this->get_path_from_lang_dir( $domain, $locale );
     95
     96        /**
     97         * Filters the determined languages directory path for a specific domain and locale.
     98         *
     99         * @since 6.6.0
     100         *
     101         * @param string|false $path   Languages directory path for the given domain and locale.
     102         * @param string       $domain Text domain.
     103         * @param string       $locale Locale.
     104         **/
     105        return apply_filters( 'lang_dir_for_domain', $path, $domain, $locale );
    99106    }
    100107
Note: See TracChangeset for help on using the changeset viewer.