Make WordPress Core


Ignore:
Timestamp:
01/23/2024 01:32:34 PM (13 months ago)
Author:
swissspidy
Message:

I18N: Introduce a more performant localization library.

This introduces a more lightweight library for loading .mo translation files which offers increased speed and lower memory usage.
It also supports loading multiple locales at the same time, which makes locale switching faster too.

For plugins interacting with the $l10n global variable in core, a shim is added to retain backward compatibility with the existing pomo library.

In addition to that, this library supports translations contained in PHP files, avoiding a binary file format and leveraging OPCache if available.
If an .mo translation file has a corresponding .l10n.php file, the latter will be loaded instead.
This behavior can be adjusted using the new translation_file_format and load_translation_file filters.

PHP translation files will be typically created by downloading language packs, but can also be generated by plugins.
See https://make.wordpress.org/core/2023/11/08/merging-performant-translations-into-core/ for more context.

Props dd32, swissspidy, flixos90, joemcgill, westonruter, akirk, SergeyBiryukov.
Fixes #59656.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-settings.php

    r57320 r57337  
    116116require ABSPATH . WPINC . '/class-wp-error.php';
    117117require ABSPATH . WPINC . '/pomo/mo.php';
     118require ABSPATH . WPINC . '/l10n/class-wp-translation-controller.php';
     119require ABSPATH . WPINC . '/l10n/class-wp-translations.php';
     120require ABSPATH . WPINC . '/l10n/class-wp-translation-file.php';
     121require ABSPATH . WPINC . '/l10n/class-wp-translation-file-mo.php';
     122require ABSPATH . WPINC . '/l10n/class-wp-translation-file-php.php';
    118123
    119124/**
     
    618623$GLOBALS['wp_locale_switcher']->init();
    619624
     625WP_Translation_Controller::instance()->set_locale( $locale );
     626
    620627// Load the functions for the active theme, for both parent and child theme if applicable.
    621628foreach ( wp_get_active_and_valid_themes() as $theme ) {
Note: See TracChangeset for help on using the changeset viewer.