https://forge.joomlapolis.com/https://forge.joomlapolis.com/favicon.ico?17095821032020-06-30T01:12:26ZJoomlapolis forgeCB Paid Subscriptions - Feature proposal #8079: Internationalization: Better pluralization of time-periodshttps://forge.joomlapolis.com/issues/8079?journal_id=207322020-06-30T01:12:26Zbeat
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/8078">Bug #8078</a>: Substitution [SUBSCRIPTION_VALIDITY_PERIOD_REMAINING] substitutes to the total period of the current subscription instead of the remaining time</i> added</li></ul> CB Paid Subscriptions - Feature proposal #8079: Internationalization: Better pluralization of time-periodshttps://forge.joomlapolis.com/issues/8079?journal_id=207342020-06-30T12:09:17Zbeat
<ul></ul><a name="Reminder-for-translators"></a>
<h1 >Reminder for translators:<a href="#Reminder-for-translators" class="wiki-anchor">¶</a></h1>
<p>CB Pluralization in translations (with one numeric substitution, e.g. "[X]" can happen as one of following (the indexed form being prefered):</p>
<ul>
<li>interval: <strong>{0} There are no apples|{1} There is one apple|]1,Inf] There are [X] apples</strong></li>
<li>indexed: <strong>There is one apple|There are [X] apples</strong></li>
</ul>
<a name="For-intervals-intervals-are-like-in-maths"></a>
<h3 >For intervals: intervals are like in maths:<a href="#For-intervals-intervals-are-like-in-maths" class="wiki-anchor">¶</a></h3>
<ul>
<li><strong>[2,5]</strong> includes 2,3,4,5,</li>
<li><strong>]2,5]</strong> includes 3,4,5,</li>
<li><strong>]2,5[</strong> includes 3 and 4.</li>
<li><strong>Inf</strong> and <strong>-Inf</strong> are infinites.</li>
</ul>
<a name="For-indexed"></a>
<h3 >For indexed:<a href="#For-indexed" class="wiki-anchor">¶</a></h3>
<ul>
<li>The indexed solution can also contain labels (e.g. one: There is one apple). This is purely for making the translations more clear - it does not affect the functionality.</li>
<li>in English and most languages, there are only 2 choices: singular|plural</li>
<li><strong>In some languages, there are more cases</strong> (up to 6 for arabic), that can be found at the end of CB file libraries/CBLib/CBLib/Language/CBTxt.php, e.g.:</li>
<li>Here a good description of the cases, separated by "|":
<ul>
<li><a class="external" href="https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals">https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals</a></li>
<li><a class="external" href="http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html">http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html</a></li>
</ul></li>
</ul>
<a name="The-two-methods-can-also-be-mixed"></a>
<h3 >The two methods can also be mixed:<a href="#The-two-methods-can-also-be-mixed" class="wiki-anchor">¶</a></h3>
<ul>
<li><strong>{0} There are no apples|one: There is one apple|more: There are <span>count</span> apples</strong></li>
</ul>
<a name="Regarding-this-feature"></a>
<h2 >Regarding this feature:<a href="#Regarding-this-feature" class="wiki-anchor">¶</a></h2>
<p>This feature introduces e.g. this translation string:</p>
<pre>
'X_YEARS' => "one year|[X] years"
</pre>
<p>2 examples: English:</p>
<p>0 hours<br />1 hour<br />2 hours<br />...</p>
<p>Translates in French (notice that 0 is singular) to:</p>
<p>0 heure<br />1 heure<br />2 heures<br />3 heures<br />...</p>
<p>Which has only 2 cases:</p>
<pre>
nplurals=2; plural=(n > 1);
</pre>
<p>But as first case has many cases as it's >1, the string must be containing the number:</p>
<pre>
'X_YEARS' => "[X] heure|[X] heures"
</pre>
<p>Alternatively to have nicer translations, it could be using a mix of the interval enumerated form for litteral exceptions, and indexed form for the numeric cases:</p>
<pre>
'X_YEARS' => "{0} aucune heure|{1} une heure|[X] heure|[X] heures"
</pre>
<p>But in Polish, it's a bit more complex with 3 forms: Particular cases for "1" and numbers ending in 2, 3 and 4 but not with 12 and 13</p>
<p>0 godzin<br />1 godzina<br />2 godziny<br />3 godziny<br />4 godziny<br />5 godzin<br />6 godzin<br />7 godzin<br />8 godzin<br />9 godzin<br />10 godzin<br />11 godzin<br />12 godzin<br />13 godzin<br />14 godzin<br />15 godzin<br />...<br />21 godzin<br />22 godziny<br />23 godziny<br />24 godziny<br />25 godzin<br />...<br />100 godzin<br />101 godzin<br />102 godziny<br />103 godziny<br />104 godziny<br />105 godzin<br />...</p>
<p>Which corresponds to this rule, found in the CB file mentionned above:</p>
<pre>
nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);
</pre>
<p>So the polish translation would be (with "one year" translating to "jedna godzina"):</p>
<pre>
'X_YEARS' => "jedna godzina|[X] godziny|[X] godzin"
</pre>
<a name="One-last-note-for-translators"></a>
<h1 >One last note for translators<a href="#One-last-note-for-translators" class="wiki-anchor">¶</a></h1>
<p>There are 3 new named strings as well:</p>
<pre>
'CB_FIRST_COMMA_OF_YEARS_COMMA_MONTHS_AND_DAYS' => ", ",
'CB_LAST_AND_OF_YEARS_COMMA_MONTHS_AND_DAYS' => " and ",
'CB_ONLY_AND_OF_YEARS_AND_MONTHS' => " and "
</pre>
<ul>
<li>Thie first 2 are f is fir the case with 3 or more date/time periods, e.g: "1 hour, 2 minutes and 3 seconds" </li>
<li>The 3rd and last is for cases with 2 date/time periods, e.g. "4 months and 5 days"</li>
</ul>
<p>Also note that for years, months and days, there are also calendar variants: E.g.:</p>
<pre>
'X_CALENDAR_YEARS' => "one calendar year|[X] calendar years"
</pre>
<p><strong>IMPORTANT</strong>: note the spaces before and after the " and ", and after the comma ", " for correct formatting.</p> CB Paid Subscriptions - Feature proposal #8079: Internationalization: Better pluralization of time-periodshttps://forge.joomlapolis.com/issues/8079?journal_id=207362020-06-30T12:13:26Zbeat
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Resolved</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Implemented in MR !200 with commit 6b3313ed3a220f2a9fe8cf28a0bf64ac0fc6cc05</p> CB Paid Subscriptions - Feature proposal #8079: Internationalization: Better pluralization of time-periodshttps://forge.joomlapolis.com/issues/8079?journal_id=207492020-07-13T17:50:51Zbeat
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/8092">Feature proposal #8092</a>: API: Date class: Add human-readable PHP output of "time ago" time scale</i> added</li></ul> CB Paid Subscriptions - Feature proposal #8079: Internationalization: Better pluralization of time-periodshttps://forge.joomlapolis.com/issues/8079?journal_id=212622020-12-10T01:38:16Zbeat
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li></ul>