<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[57516] trunk: I18N: Support loading `.l10n.php` translation files on their own.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/57516">57516</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/57516","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>swissspidy</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-01 19:03:55 +0000 (Thu, 01 Feb 2024)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>I18N: Support loading `.l10n.php` translation files on their own.
Adjusts the translation file lookup in `WP_Textdomain_Registry` so that just-in-time translation loading
works even if there is only a `.l10n.php` translation file without a corresponding `.mo` file.
While language packs continue to contain both file types, this makes it easier to use translations in a project
without having to deal with `.mo` or `.po` files.
Props Chrystl.
See <a href="https://core.trac.wordpress.org/ticket/59656">#59656</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswptextdomainregistryphp">trunk/src/wp-includes/class-wp-textdomain-registry.php</a></li>
<li><a href="#trunksrcwpincludesl10nphp">trunk/src/wp-includes/l10n.php</a></li>
<li><a href="#trunktestsphpunittestsl10nloadTextdomainJustInTimephp">trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php</a></li>
<li><a href="#trunktestsphpunittestsl10nwpTextdomainRegistryphp">trunk/tests/phpunit/tests/l10n/wpTextdomainRegistry.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunitdatalanguagespluginsinternationalizedplugin2de_DEl10nphp">trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-de_DE.l10n.php</a></li>
<li><a href="#trunktestsphpunitdatalanguagespluginsinternationalizedplugin2es_ESl10nphp">trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-es_ES.l10n.php</a></li>
<li><a href="#trunktestsphpunitdatapluginsinternationalizedplugin2php">trunk/tests/phpunit/data/plugins/internationalized-plugin-2.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswptextdomainregistryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-textdomain-registry.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-textdomain-registry.php 2024-02-01 16:26:47 UTC (rev 57515)
+++ trunk/src/wp-includes/class-wp-textdomain-registry.php 2024-02-01 19:03:55 UTC (rev 57516)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,7 +150,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieves .mo files from the specified path.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Retrieves translation files from the specified path.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Allows early retrieval through the {@see 'pre_get_mo_files_from_path'} filter to optimize
</span><span class="cx" style="display: block; padding: 0 10px"> * performance, especially in directories with many files.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,14 +157,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path The directory path to search for .mo files.
- * @return array Array of .mo file paths.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $path The directory path to search for translation files.
+ * @return array Array of translation file paths. Can contain .mo and .l10n.php files.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_language_files_from_path( $path ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $path = rtrim( $path, '/' ) . '/';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Filters the .mo files retrieved from a specified path before the actual lookup.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Filters the translation files retrieved from a specified path before the actual lookup.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Returning a non-null value from the filter will effectively short-circuit
</span><span class="cx" style="display: block; padding: 0 10px"> * the MO files lookup, returning that value instead.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -174,27 +174,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param null|array $mo_files List of .mo files. Default null.
- * @param string $path The path from which .mo files are being fetched.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param null|array $files List of translation files. Default null.
+ * @param string $path The path from which translation files are being fetched.
</ins><span class="cx" style="display: block; padding: 0 10px"> **/
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mo_files = apply_filters( 'pre_get_language_files_from_path', null, $path );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $files = apply_filters( 'pre_get_language_files_from_path', null, $path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( null !== $mo_files ) {
- return $mo_files;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( null !== $files ) {
+ return $files;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cache_key = 'cached_mo_files_' . md5( $path );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mo_files = wp_cache_get( $cache_key, 'translations' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $files = wp_cache_get( $cache_key, 'translations' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( false === $mo_files ) {
- $mo_files = glob( $path . '*.mo' );
- if ( false === $mo_files ) {
- $mo_files = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( false === $files ) {
+ $files = glob( $path . '*.mo' );
+ if ( false === $files ) {
+ $files = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_cache_set( $cache_key, $mo_files, 'translations' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $php_files = glob( $path . '*.l10n.php' );
+ if ( is_array( $php_files ) ) {
+ $files = array_merge( $files, $php_files );
+ }
+
+ wp_cache_set( $cache_key, $files, 'translations' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $mo_files;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $files;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -295,17 +301,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $locations as $location ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $files = $this->get_language_files_from_path( $location );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $path = "$location/$domain-$locale.mo";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $mo_path = "$location/$domain-$locale.mo";
+ $php_path = "$location/$domain-$locale.l10n.php";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $files as $mo_path ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $files as $file_path ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> ! in_array( $domain, $this->domains_with_translations, true ) &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- str_starts_with( str_replace( "$location/", '', $mo_path ), "$domain-" )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ str_starts_with( str_replace( "$location/", '', $file_path ), "$domain-" )
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->domains_with_translations[] = $domain;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $mo_path === $path ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $file_path === $mo_path || $file_path === $php_path ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $found_location = rtrim( $location, '/' ) . '/';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesl10nphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/l10n.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/l10n.php 2024-02-01 16:26:47 UTC (rev 57515)
+++ trunk/src/wp-includes/l10n.php 2024-02-01 19:03:55 UTC (rev 57516)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -789,10 +789,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_readable( $mofile ) ) {
- return false;
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! $locale ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $locale = determine_locale();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -817,14 +813,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $preferred_format = 'php';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $translation_files = array( $mofile );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $translation_files = array();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'mo' !== $preferred_format ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array_unshift(
- $translation_files,
- substr_replace( $mofile, ".l10n.$preferred_format", - strlen( '.mo' ) )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $translation_files[] = substr_replace( $mofile, ".l10n.$preferred_format", - strlen( '.mo' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $translation_files[] = $mofile;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $translation_files as $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the file path for loading translations for the given text domain.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -857,7 +853,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return false;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunitdatalanguagespluginsinternationalizedplugin2de_DEl10nphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-de_DE.l10n.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-de_DE.l10n.php (rev 0)
+++ trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-de_DE.l10n.php 2024-02-01 19:03:55 UTC (rev 57516)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,2 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=(n != 1);','messages'=>['This is a dummy plugin'=>'Das ist ein Dummy Plugin'],'language'=>'de_DE','x-generator'=>'Poedit 2.4.1'];
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-de_DE.l10n.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitdatalanguagespluginsinternationalizedplugin2es_ESl10nphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-es_ES.l10n.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-es_ES.l10n.php (rev 0)
+++ trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-es_ES.l10n.php 2024-02-01 19:03:55 UTC (rev 57516)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,2 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=(n != 1);','messages'=>['This is a dummy plugin'=>'Este es un plugin dummy'],'language'=>'de_DE','x-generator'=>'Poedit 2.4.1'];
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-2-es_ES.l10n.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitdatapluginsinternationalizedplugin2php"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/data/plugins/internationalized-plugin-2.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/plugins/internationalized-plugin-2.php (rev 0)
+++ trunk/tests/phpunit/data/plugins/internationalized-plugin-2.php 2024-02-01 19:03:55 UTC (rev 57516)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,12 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/*
+Plugin Name: Dummy Plugin 2
+Plugin URI: https://wordpress.org/
+Description: For testing purposes only. Only has an .l10n.php translation file.
+Version: 1.0.0
+Text Domain: internationalized-plugin
+*/
+
+function i18n_plugin_2_test() {
+ return __( 'This is a dummy plugin', 'internationalized-plugin-2' );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/data/plugins/internationalized-plugin-2.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestsl10nloadTextdomainJustInTimephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php 2024-02-01 16:26:47 UTC (rev 57515)
+++ trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php 2024-02-01 19:03:55 UTC (rev 57516)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,6 +49,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_textdomain_registry = new WP_Textdomain_Registry();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> unload_textdomain( 'internationalized-plugin' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unload_textdomain( 'internationalized-plugin-2' );
</ins><span class="cx" style="display: block; padding: 0 10px"> unload_textdomain( 'internationalized-theme' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> parent::tear_down();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,6 +88,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 59656
+ *
+ * @covers ::is_textdomain_loaded
+ */
+ public function test_plugin_translation_should_be_translated_with_only_an_l10n_php_file() {
+ add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
+
+ require_once DIR_TESTDATA . '/plugins/internationalized-plugin-2.php';
+
+ $is_textdomain_loaded_before = is_textdomain_loaded( 'internationalized-plugin-2' );
+ $actual_output = i18n_plugin_2_test();
+ $is_textdomain_loaded_after = is_textdomain_loaded( 'internationalized-plugin-2' );
+
+ remove_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
+
+ $this->assertFalse( $is_textdomain_loaded_before );
+ $this->assertSame( 'Das ist ein Dummy Plugin', $actual_output );
+ $this->assertTrue( $is_textdomain_loaded_after );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34114
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::is_textdomain_loaded
</span></span></pre></div>
<a id="trunktestsphpunittestsl10nwpTextdomainRegistryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/l10n/wpTextdomainRegistry.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/l10n/wpTextdomainRegistry.php 2024-02-01 16:26:47 UTC (rev 57515)
+++ trunk/tests/phpunit/tests/l10n/wpTextdomainRegistry.php 2024-02-01 19:03:55 UTC (rev 57516)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -151,36 +151,46 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function data_domains_locales() {
</span><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Non-existent plugin' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Non-existent plugin' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'unknown-plugin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'en_US',
</span><span class="cx" style="display: block; padding: 0 10px"> false,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Non-existent plugin with de_DE' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Non-existent plugin with de_DE' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'unknown-plugin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'de_DE',
</span><span class="cx" style="display: block; padding: 0 10px"> false,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Available de_DE translations' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Available de_DE translations' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'internationalized-plugin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'de_DE',
</span><span class="cx" style="display: block; padding: 0 10px"> WP_LANG_DIR . '/plugins/',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Available es_ES translations' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Available es_ES translations' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'internationalized-plugin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'es_ES',
</span><span class="cx" style="display: block; padding: 0 10px"> WP_LANG_DIR . '/plugins/',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Unavailable fr_FR translations' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Unavailable fr_FR translations' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'internationalized-plugin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'fr_FR',
</span><span class="cx" style="display: block; padding: 0 10px"> false,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Unavailable en_US translations' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Unavailable en_US translations' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'internationalized-plugin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'en_US',
</span><span class="cx" style="display: block; padding: 0 10px"> false,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Available de_DE translations (.l10n.php)' => array(
+ 'internationalized-plugin-2',
+ 'de_DE',
+ WP_LANG_DIR . '/plugins/',
+ ),
+ 'Available es_ES translations (.l10n.php)' => array(
+ 'internationalized-plugin-2',
+ 'es_ES',
+ WP_LANG_DIR . '/plugins/',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>