Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Yii Framework 2 Change Log

- Bug #21150: Fix `yii\web\AssetManager` ignoring the `only`, `except`, `beforeCopy` and `afterCopy` publish options when `linkAssets` is enabled, which published files excluded by these options (rob006)
- Enh #21150: Add the `files` publish option to `yii\web\AssetManager::publish()` to publish only the listed files and directories of an asset bundle (rob006)
- Bug #21145: Fix Latin letters in Cyrillic words of the Serbian (`sr`) framework messages (bardrop)
- Bug #21073: Fix `MultipartFormDataParser` boundary extraction when `Content-Type` has additional parameters (iliaal)
- Bug #21121: Fix `yii\validators\DateValidator` rejecting non-ASCII dates on PHP 8.4.27 and 8.5.12 (eluhr)
- Bug #21020: Fix duplicate `@return` annotation for `yii\db\ActiveRecord::hasOne()` (nazard)
Expand Down
6 changes: 3 additions & 3 deletions framework/messages/sr/yii.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'Page not found.' => 'Страница није пронађена.',
'Please fix the following errors:' => 'Молимо вас исправите следеће грешке:',
'Please upload a file.' => 'Молимо вас поставите фајл.',
'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.' => 'Приказано <b>{begin, number}-{end, number}</b> од <b>{totalCount, number}</b> {totalCount, plural, =1{ставке} one{ставкe} few{ставке} many{ставки} other{ставки}}.',
'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.' => 'Приказано <b>{begin, number}-{end, number}</b> од <b>{totalCount, number}</b> {totalCount, plural, =1{ставке} one{ставке} few{ставке} many{ставки} other{ставки}}.',
'The combination {values} of {attributes} has already been taken.' => '',
'The file "{file}" is not an image.' => 'Фајл "{file}" није слика.',
'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => 'Фајл "{file}" је превелик. Величина не може бити већа од {formattedLimit}.',
Expand All @@ -72,12 +72,12 @@
'View' => 'Приказ',
'Yes' => 'Да',
'You are not allowed to perform this action.' => 'Немате права да извршите ову акцију.',
'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => 'Можете поставити највише {limit, number} {limit, plural, one{фајл} few{фајлa} other{фајлова}}.',
'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => 'Можете поставити највише {limit, number} {limit, plural, one{фајл} few{фајла} other{фајлова}}.',
'You should upload at least {limit, number} {limit, plural, one{file} other{files}}.' => '',
'in {delta, plural, =1{a day} other{# days}}' => 'за {delta, plural, =1{дан} one{# дан} few{# дана} many{# дана} other{# дана}}',
'in {delta, plural, =1{a minute} other{# minutes}}' => 'за {delta, plural, =1{минут} one{# минут} few{# минута} many{# минута} other{# минута}}',
'in {delta, plural, =1{a month} other{# months}}' => 'за {delta, plural, =1{месец} one{# месец} few{# месеца} many{# месеци} other{# месеци}}',
'in {delta, plural, =1{a second} other{# seconds}}' => 'за {delta, plural, =1{секунду} one{# секунду} few{# секундe} many{# секунди} other{# секунди}}',
'in {delta, plural, =1{a second} other{# seconds}}' => 'за {delta, plural, =1{секунду} one{# секунду} few{# секунде} many{# секунди} other{# секунди}}',
'in {delta, plural, =1{a year} other{# years}}' => 'за {delta, plural, =1{годину} one{# годину} few{# године} many{# година} other{# година}}',
'in {delta, plural, =1{an hour} other{# hours}}' => 'за {delta, plural, =1{сат} one{# сат} few{# сата} many{# сати} other{# сати}}',
'just now' => 'управо сада',
Expand Down
44 changes: 44 additions & 0 deletions tests/framework/i18n/FrameworkMessagesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/

declare(strict_types=1);

namespace yiiunit\framework\i18n;

use yiiunit\TestCase;

/**
* Checks the translations in `framework/messages`.
*
* @group i18n
*/
final class FrameworkMessagesTest extends TestCase
{
public function testWordsDoNotMixAlphabets(): void
{
$invalid = [];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$invalid = [];
/**
* @dataProvider serbianMessageProvider
*/
public function testSerbianPluralTranslations(string $message, array $params, string $expected): void
{
$this->mockApplication();
$this->assertSame($expected, Yii::t('yii', $message, $params, 'sr'));
}
public static function serbianMessageProvider(): array
{
return [
'pagination uses one for 21 items' => [
'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> '
. '{totalCount, plural, one{item} other{items}}.',
['begin' => 1, 'end' => 10, 'totalCount' => 21],
'Приказано <b>1-10</b> од <b>21</b> ставке.',
],
'upload limit uses few for two files' => [
'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.',
['limit' => 2],
'Можете поставити највише 2 фајла.',
],
'relative time uses few for two seconds' => [
'in {delta, plural, =1{a second} other{# seconds}}',
['delta' => 2],
'за 2 секунде',
],
];
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 0132403, thanks. All three cases fail on master and pass here. I kept the mixed-alphabet scan next to it since it covers the other languages; I can drop it if you only want this test.


foreach (glob(__DIR__ . '/../../../framework/messages/*/yii.php') as $file) {
$language = basename(dirname($file));

foreach (require $file as $translation) {
foreach (preg_split('/[^\p{L}\p{M}]+/u', $translation, -1, PREG_SPLIT_NO_EMPTY) as $word) {
$alphabets = preg_match('/(?![\p{Cyrillic}\p{Greek}])\p{Latin}/u', $word)
+ preg_match('/(?![\p{Latin}\p{Greek}])\p{Cyrillic}/u', $word)
+ preg_match('/(?![\p{Latin}\p{Cyrillic}])\p{Greek}/u', $word);

if ($alphabets > 1) {
$invalid[] = "$language: $word";
}
}
}
}

$this->assertSame([], array_values(array_unique($invalid)));
}
}
Loading