Commit Graph

3 Commits

Author SHA1 Message Date
Pascal Birchler
64ca037991 I18N: Rename WP_Translation_Controller::instance() method to get_instance().
This improves consistency as `get_instance()` is more commonly used in core. 

See #59656.
Built from https://develop.svn.wordpress.org/trunk@57350


git-svn-id: http://core.svn.wordpress.org/trunk@56856 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-25 07:53:17 +00:00
Pascal Birchler
97518917dd I18N: Improve edge case handling in WP_Translation_Controller.
Prevents PHP warnings for possibly undefined array keys.
Also fixes incorrect `@covers` annotations.

Follow-up to [57337].
See #59656.
Built from https://develop.svn.wordpress.org/trunk@57339


git-svn-id: http://core.svn.wordpress.org/trunk@56845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-23 15:15:14 +00:00
Pascal Birchler
c6ccfb1242 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.
Built from https://develop.svn.wordpress.org/trunk@57337


git-svn-id: http://core.svn.wordpress.org/trunk@56843 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-23 13:34:11 +00:00