Make WordPress Core


Ignore:
Timestamp:
02/01/2024 07:03:55 PM (16 months ago)
Author:
swissspidy
Message:

I18N: Support loading .l10n.php translation files on their own.

Adjusts the translation file lookup in WP_Textdomain_Registry so that just-in-time translation loading
works even if there is only a .l10n.php translation file without a corresponding .mo file.

While language packs continue to contain both file types, this makes it easier to use translations in a project
without having to deal with .mo or .po files.

Props Chrystl.
See #59656.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r57350 r57516  
    790790    $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
    791791
    792     if ( ! is_readable( $mofile ) ) {
    793         return false;
    794     }
    795 
    796792    if ( ! $locale ) {
    797793        $locale = determine_locale();
     
    818814    }
    819815
    820     $translation_files = array( $mofile );
     816    $translation_files = array();
     817
    821818    if ( 'mo' !== $preferred_format ) {
    822         array_unshift(
    823             $translation_files,
    824             substr_replace( $mofile, ".l10n.$preferred_format", - strlen( '.mo' ) )
    825         );
    826     }
     819        $translation_files[] = substr_replace( $mofile, ".l10n.$preferred_format", - strlen( '.mo' ) );
     820    }
     821
     822    $translation_files[] = $mofile;
    827823
    828824    foreach ( $translation_files as $file ) {
     
    858854    }
    859855
    860     return true;
     856    return false;
    861857}
    862858
Note: See TracChangeset for help on using the changeset viewer.