PHP Files Instead Of MO Files

This article is part of the WordPress guide. Read the introduction.

Table of Contents

WordPress 6.5 introduced significant performance optimizations to the server-side translation system. Namely, it became possible to store translations in PHP files instead of MO files.

Why is that a big deal? To get a long answer, you should go read the dev note for that. The short answer is that loading PHP files is much cheaper than loading and processing binary MO files. The translations are already stored in an array and you benefit from OPCache (if available).

Overall, it has been found that loading translations from PHP files improves the speed of your website by about 40 ms. That is a lot for such a small thing. Since 6.5, WordPress prioritizes those PHP files over MO files.

To generate PHP l10n files, you can run the “wp i18n make-php” command. This will generate the PHP files from your PO files. Their filename form is: {text-domain}-{locale}.l10n.php. If we run this command, the generated file will be named post-reading-time-pl_PL.l10n.php. Here is its content:

PHP
<?php
return ['domain'=>'post-reading-time','plural-forms'=>'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);',
'language'=>'','project-id-version'=>'Post Reading Time','pot-creation-date'=>'2025-08-28T09:59:52+00:00','po-revision-date'=>'YEAR-MO-DA HO:MI+ZONE',
'x-generator'=>'WP-CLI 2.12.0','messages'=>['Post Reading Time'=>'Czas Czytania Wpisu','Reading time'=>'Czas czytania','min'=>'minuta' . "\0" . 'minuty' . "\0" . 'minut',
'%1$s: %2$d %3$s'=>'%2$d %3$s - %1$s','Settings related to text'=>'Ustawienia związane z tekstem','Text Settings'=>'Ustawienia tekstu',
'Text alternative to "Reading time"'=>'Alternatywa dla "Czas czytania"','Post Reading Time Settings'=>'Ustawienia Czasu Czytania Wpisu',
'settings submenu titlePost Reading Time'=>'Czas Czytania Wpisu','Thank you for downloading my plugin!'=>'Dziękuję za zainstalowania mojej wtyczki!']];

Alternatively, you can install the Performant Translations plugin. This is the project that started it all and it’s still being developed. It automatically generates those PHP files for all themes/plugins that do not yet have them.

Table of Contents