<!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>[57734] trunk/src/wp-includes/pomo: I18N: Improve docs for pomo library classes.</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/57734">57734</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/57734","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-28 09:29:03 +0000 (Wed, 28 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: Improve docs for pomo library classes.
Props subrataemfluence, pento, hrshahin.
Fixes <a href="https://core.trac.wordpress.org/ticket/44424">#44424</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludespomoentryphp">trunk/src/wp-includes/pomo/entry.php</a></li>
<li><a href="#trunksrcwpincludespomotranslationsphp">trunk/src/wp-includes/pomo/translations.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludespomoentryphp"></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/pomo/entry.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/pomo/entry.php 2024-02-27 23:05:18 UTC (rev 57733)
+++ trunk/src/wp-includes/pomo/entry.php 2024-02-28 09:29:03 UTC (rev 57734)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,6 +10,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'Translation_Entry', false ) ) :
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Translation_Entry class encapsulates a translatable string.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @since 2.8.0
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> #[AllowDynamicProperties]
</span><span class="cx" style="display: block; padding: 0 10px"> class Translation_Entry {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -75,6 +77,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * PHP4 constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
</ins><span class="cx" style="display: block; padding: 0 10px"> * @deprecated 5.4.0 Use __construct() instead.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see Translation_Entry::__construct()
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,6 +90,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Generates a unique key for this entry.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string|false The key or false if the entry is null.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function key() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -103,7 +108,11 @@
</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">- * @param object $other
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Merges another translation entry with the current one.
+ *
+ * @since 2.8.0
+ *
+ * @param Translation_Entry $other Other translation entry.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function merge_with( &$other ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->flags = array_unique( array_merge( $this->flags, $other->flags ) );
</span></span></pre></div>
<a id="trunksrcwpincludespomotranslationsphp"></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/pomo/translations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/pomo/translations.php 2024-02-27 23:05:18 UTC (rev 57733)
+++ trunk/src/wp-includes/pomo/translations.php 2024-02-28 09:29:03 UTC (rev 57734)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,6 +5,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @version $Id: translations.php 1157 2015-11-20 04:30:11Z dd32 $
</span><span class="cx" style="display: block; padding: 0 10px"> * @package pomo
</span><span class="cx" style="display: block; padding: 0 10px"> * @subpackage translations
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
</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"> require_once __DIR__ . '/plural-forms.php';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,16 +12,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require_once __DIR__ . '/entry.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'Translations', false ) ) :
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Translations class.
+ *
+ * @since 2.8.0
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> #[AllowDynamicProperties]
</span><span class="cx" style="display: block; padding: 0 10px"> class Translations {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * List of translation entries.
+ *
+ * @since 2.8.0
+ *
+ * @var Translation_Entry[]
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public $entries = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * List of translation headers.
+ *
+ * @since 2.8.0
+ *
+ * @var array<string, string>
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public $headers = array();
</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">- * Add entry to the PO structure
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Adds an entry to the PO structure.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array|Translation_Entry $entry
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool true on success, false if the entry doesn't have a key
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false if the entry doesn't have a key.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function add_entry( $entry ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $entry ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,8 +58,12 @@
</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">+ * Adds or merges an entry to the PO structure.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array|Translation_Entry $entry
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false if the entry doesn't have a key.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function add_entry_or_merge( $entry ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $entry ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -61,6 +88,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * TODO: this should be out of this class, it is gettext specific
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $header header name, without trailing :
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $value header value, without trailing \n
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,7 +98,11 @@
</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">- * @param array $headers
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets translation headers.
+ *
+ * @since 2.8.0
+ *
+ * @param array $headers Associative array of headers.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_headers( $headers ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $headers as $header => $value ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,7 +111,12 @@
</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">+ * Returns a given translation header.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $header
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string|false Header if it exists, false otherwise.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_header( $header ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return isset( $this->headers[ $header ] ) ? $this->headers[ $header ] : false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -85,7 +123,12 @@
</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">- * @param Translation_Entry $entry
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns a given translation entry.
+ *
+ * @since 2.8.0
+ *
+ * @param Translation_Entry $entry Translation entry.
+ * @return Translation_Entry|false Translation entry if it exists, false otherwise.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function translate_entry( &$entry ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $key = $entry->key();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,6 +136,10 @@
</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">+ * Translates a singular string.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $singular
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $context
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -117,7 +164,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * This function should be overridden by the subclasses. For example MO/PO can derive the logic
</span><span class="cx" style="display: block; padding: 0 10px"> * from their headers.
</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 int $count number of items
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ *
+ * @param int $count Number of items.
+ * @return int Plural form to use.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function select_plural_form( $count ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return 1 === (int) $count ? 0 : 1;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -124,7 +174,11 @@
</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 int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the plural forms count.
+ *
+ * @since 2.8.0
+ *
+ * @return int Plural forms count.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_plural_forms_count() {
</span><span class="cx" style="display: block; padding: 0 10px"> return 2;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -131,10 +185,15 @@
</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">+ * Translates a plural string.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $singular
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $plural
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $count
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $context
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function translate_plural( $singular, $plural, $count, $context = null ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $entry = new Translation_Entry(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,9 +216,11 @@
</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">- * Merge $other in the current object.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Merges other translations into the current one.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param Object $other Another Translation object, whose translations will be merged in this one (passed by reference).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ *
+ * @param Translations $other Another Translation object, whose translations will be merged in this one (passed by reference).
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function merge_with( &$other ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $other->entries as $entry ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,7 +229,11 @@
</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">- * @param object $other
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Merges originals with existing entries.
+ *
+ * @since 2.8.0
+ *
+ * @param Translations $other
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function merge_originals_with( &$other ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $other->entries as $entry ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -181,6 +246,11 @@
</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">+ /**
+ * Gettext_Translations class.
+ *
+ * @since 2.8.0
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> class Gettext_Translations extends Translations {
</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">@@ -187,6 +257,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Number of plural forms.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @var int
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @since 2.8.0
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $_nplurals;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -194,6 +266,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Callback to retrieve the plural form.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @var callable
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @since 2.8.0
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $_gettext_select_plural_form;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,10 +274,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The gettext implementation of select_plural_form.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * It lives in this class, because there are more than one descendand, which will use it and
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * It lives in this class, because there are more than one descendant, which will use it and
</ins><span class="cx" style="display: block; padding: 0 10px"> * they can't share it effectively.
</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 int $count
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ *
+ * @param int $count Plural forms count.
+ * @return int Plural form to use.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function gettext_select_plural_form( $count ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $this->_gettext_select_plural_form ) || is_null( $this->_gettext_select_plural_form ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,8 +292,12 @@
</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">+ * Returns the nplurals and plural forms expression from the Plural-Forms header.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $header
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array{0: int, 1: string}
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function nplurals_and_expression_from_header( $header ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( preg_match( '/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -230,10 +311,13 @@
</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"> * Makes a function, which will return the right translation index, according to the
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * plural forms header
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * plural forms header.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int $nplurals
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $expression
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return callable
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function make_plural_form_function( $nplurals, $expression ) {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -249,7 +333,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Adds parentheses to the inner parts of ternary operators in
</span><span class="cx" style="display: block; padding: 0 10px"> * plural expressions, because PHP evaluates ternary operators from left to right
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
</ins><span class="cx" style="display: block; padding: 0 10px"> * @deprecated 6.5.0 Use the Plural_Forms class instead.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see Plural_Forms
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $expression the expression without parentheses
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -281,8 +367,12 @@
</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">+ * Prepare translation headers.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $translation
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array<string, string> Translation headers
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function make_headers( $translation ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -300,6 +390,10 @@
</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">+ * Sets translation headers.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $header
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -316,11 +410,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'NOOP_Translations', 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">- * Provides the same interface as Translations, but doesn't do anything
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Provides the same interface as Translations, but doesn't do anything.
+ *
+ * @since 2.8.0
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> #[AllowDynamicProperties]
</span><span class="cx" style="display: block; padding: 0 10px"> class NOOP_Translations {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * List of translation entries.
+ *
+ * @since 2.8.0
+ *
+ * @var Translation_Entry[]
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public $entries = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * List of translation headers.
+ *
+ * @since 2.8.0
+ *
+ * @var array<string, string>
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public $headers = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function add_entry( $entry ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -328,6 +439,10 @@
</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">+ * Sets a translation header.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $header
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -335,6 +450,10 @@
</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">+ * Sets translation headers.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $headers
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_headers( $headers ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -341,6 +460,10 @@
</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">+ * Returns a translation header.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $header
</span><span class="cx" style="display: block; padding: 0 10px"> * @return false
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -349,6 +472,10 @@
</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">+ * Returns a given translation entry.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param Translation_Entry $entry
</span><span class="cx" style="display: block; padding: 0 10px"> * @return false
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -357,6 +484,10 @@
</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">+ * Translates a singular string.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $singular
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $context
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -365,8 +496,12 @@
</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">+ * Returns the plural form to use.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int $count
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return int
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function select_plural_form( $count ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return 1 === (int) $count ? 0 : 1;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -373,6 +508,10 @@
</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">+ * Returns the plural forms count.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_plural_forms_count() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -380,10 +519,15 @@
</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">+ * Translates a plural string.
+ *
+ * @since 2.8.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $singular
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $plural
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $count
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $context
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function translate_plural( $singular, $plural, $count, $context = null ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return 1 === (int) $count ? $singular : $plural;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -390,7 +534,11 @@
</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">- * @param object $other
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Merges other translations into the current one.
+ *
+ * @since 2.8.0
+ *
+ * @param Translations $other
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function merge_with( &$other ) {
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>