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.