A faster load_textdomain

Mô tả

NOTE This plugin is not needed if you are running WordPress 6.5 or later, as the functionality is built into WordPress core. If you need to generate translation in the new .l10n.php format, use the Performant Translations plugin instead.

This is a WordPress plugin that caches the .mo file as an PHP array, and include the array instead of the .mo file.
In theory, nothing is faster in PHP than loading and executing another PHP file.

How it works

If you have a plugin or theme that loads a textdomain, e.g. load_textdomain( 'textdomain', $path_to_mo_file ), then this plugin will:

  1. Look for a PHP version of the .mo file in WP_CONTENT_DIR . '/cache/a-faster-load-textdomain' directory.
  2. If the PHP version exists, include the file.
  3. If the PHP version doesn’t exist, load the .mo file, and save the file as an PHP array in wp-content/cache/a-faster-load-textdomain/ directory.

The localized PHP array can be cached via PHP OPcache. If you have PHP OPcache enabled, then the localized PHP array will be cached in memory, and the PHP file will not be parsed again.



Change the cache path, default is WP_CONTENT_DIR . '/cache/a-faster-load-textdomain'.

add_filter( 'a_faster_load_textdomain_cache_path', function( $path ) {
    return WP_CONTENT_DIR . '/cache/my-cache';
} );


The plugin source is available at GitHub

Cài đặt

Either (recommended):
– Download the plugin files and extract a-faster-load-textdomain.php and class-afld-cachehandler.php to the wp-content/mu-plugins directory.

– Search for “A faster load_textdomain” and install with the WordPress plugin installer.
– (Network) Activate the plugin through the ‘Plugins’ menu in WordPress.

It’s also possible to install the plugin via Composer:

composer require soderlind/a-faster-load-textdomain

Đánh giá

There are no reviews for this plugin.

Người đóng góp & Lập trình viên

“A faster load_textdomain” là mã nguồn mở. Những người sau đã đóng góp vào plugin này.

Những người đóng góp

“A faster load_textdomain” đã được dịch qua 4 ngôn ngữ. Cảm ơn những người tham gia dịch vì đóng góp của họ.

Dịch “A faster load_textdomain” sang ngôn ngữ của bạn.

Muốn tham gia phát triển?

Duyệt code, check out SVN repository, hoặc theo dõi nhật ký phát triển qua RSS.

Nhật ký thay đổi


  • Catch errors in the cache handler. If the cache file is corrupt, update the file and return the .mo file.


  • If running WordPress 6.5, give a notice that the plugin is not needed.


  • Fail gracefully if cache directory can’t be created.


  • Housekeeping.


  • Add uninstall handler. Will remove the cache directory when the plugin is uninstalled.


  • Fix bug in cache handler.


  • Refactor cache handler.


  • Bump version to force deploy to WordPress.org


  • Deploy with GitHub Actions to WordPress.org


  • Remove mkdir()


  • Fail gracefully if $cache_path can’t be created.


  • Add aflt_load_textdomain filter.


  • Rename namespace to Soderlind\Plugin\A_Faster_Load_Textdomain
  • Rename cache directory to WP_CONTENT_DIR . '/cache/a-faster-load-textdomain'


  • Rename file to a-faster-load-textdomain.php to follow WordPress plugin standards.


  • Refactor code, instead of using a transient, save .mo file as an PHP array, and include the array instead of the .mo file.


  • Housekeeping.


  • DRY (Don’t Repeat Yourself) code. Add namespace.


  • Add multisite support


  • Initial release