Skip to content

Commit 833f335

Browse files
authored
Merge branch 'master' into bugfix/20002-Superfluous_query_on_HEAD_request_in_serializer
2 parents f283868 + e029988 commit 833f335

File tree

2 files changed

+52
-31
lines changed

2 files changed

+52
-31
lines changed

framework/helpers/BaseFormatConverter.php

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,13 @@ class BaseFormatConverter
9797
* @param string|null $locale the locale to use for converting ICU short patterns `short`, `medium`, `long` and `full`.
9898
* If not given, `Yii::$app->language` will be used.
9999
* @return string The converted date format pattern.
100+
* @throws \Exception
100101
*/
101102
public static function convertDateIcuToPhp($pattern, $type = 'date', $locale = null)
102103
{
103104
if (isset(self::$_icuShortFormats[$pattern])) {
104105
if (extension_loaded('intl')) {
105-
if ($locale === null) {
106-
$locale = Yii::$app->language;
107-
}
108-
if ($type === 'date') {
109-
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], IntlDateFormatter::NONE);
110-
} elseif ($type === 'time') {
111-
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::NONE, self::$_icuShortFormats[$pattern]);
112-
} else {
113-
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], self::$_icuShortFormats[$pattern]);
114-
}
115-
$pattern = $formatter->getPattern();
106+
$pattern = static::createFormatter($locale, $type, $pattern);
116107
} else {
117108
return static::$phpFallbackDatePatterns[$pattern][$type];
118109
}
@@ -350,22 +341,13 @@ public static function convertDatePhpToIcu($pattern)
350341
* @param string|null $locale the locale to use for converting ICU short patterns `short`, `medium`, `long` and `full`.
351342
* If not given, `Yii::$app->language` will be used.
352343
* @return string The converted date format pattern.
344+
* @throws \Exception
353345
*/
354346
public static function convertDateIcuToJui($pattern, $type = 'date', $locale = null)
355347
{
356348
if (isset(self::$_icuShortFormats[$pattern])) {
357349
if (extension_loaded('intl')) {
358-
if ($locale === null) {
359-
$locale = Yii::$app->language;
360-
}
361-
if ($type === 'date') {
362-
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], IntlDateFormatter::NONE);
363-
} elseif ($type === 'time') {
364-
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::NONE, self::$_icuShortFormats[$pattern]);
365-
} else {
366-
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], self::$_icuShortFormats[$pattern]);
367-
}
368-
$pattern = $formatter->getPattern();
350+
$pattern = static::createFormatter($locale, $type, $pattern);
369351
} else {
370352
return static::$juiFallbackDatePatterns[$pattern][$type];
371353
}
@@ -545,4 +527,32 @@ public static function convertDatePhpToJui($pattern)
545527
'U' => '@', // Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
546528
]);
547529
}
530+
531+
/**
532+
* Creates a date/time formatter based on the given parameters.
533+
*
534+
* @param string|null $locale The locale to be used. If null, the application's current language will be used.
535+
* @param string $type The type of formatter ('date', 'time', etc.)
536+
* @param string $pattern The pattern for the IntlDateFormatter.
537+
*
538+
* @return string The resulting pattern after formatter creation.
539+
*
540+
* @throws \Exception If the 'intl' extension is not loaded.
541+
*/
542+
private static function createFormatter($locale, $type, $pattern)
543+
{
544+
if ($locale === null) {
545+
$locale = Yii::$app->language;
546+
}
547+
548+
if ($type === 'date') {
549+
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], IntlDateFormatter::NONE);
550+
} elseif ($type === 'time') {
551+
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::NONE, self::$_icuShortFormats[$pattern]);
552+
} else {
553+
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], self::$_icuShortFormats[$pattern]);
554+
}
555+
556+
return $formatter->getPattern();
557+
}
548558
}

framework/messages/fa/yii.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
'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> مورد.',
4646
'The combination {values} of {attributes} has already been taken.' => 'مقدار {values} از {attributes} قبلاً گرفته شده است.',
4747
'The file "{file}" is not an image.' => 'فایل "{file}" یک تصویر نیست.',
48-
'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => 'حجم فایل "{file}" بسیار بیشتر می باشد. حجم آن نمی تواند از {formattedLimit} بیشتر باشد.',
49-
'The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}.' => 'حجم فایل "{file}" بسیار کم می باشد. حجم آن نمی تواند از {formattedLimit} کمتر باشد.',
48+
'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => 'حجم فایل "{file}" بسیار بیشتر میباشد. حجم آن نمیتواند از {formattedLimit} بیشتر باشد.',
49+
'The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}.' => 'حجم فایل "{file}" بسیار کم میباشد. حجم آننمی تواند از {formattedLimit} کمتر باشد.',
5050
'The format of {attribute} is invalid.' => 'قالب {attribute} نامعتبر است.',
5151
'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'تصویر "{file}" خیلی بزرگ است. ارتفاع نمی‌تواند بزرگتر از {limit, number} پیکسل باشد.',
5252
'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'تصویر "{file}" خیلی بزرگ است. عرض نمی‌تواند بزرگتر از {limit, number} پیکسل باشد.',
@@ -71,9 +71,9 @@
7171
'in {delta, plural, =1{an hour} other{# hours}}' => '{delta} ساعت دیگر',
7272
'just now' => 'هم اکنون',
7373
'the input value' => 'مقدار ورودی',
74-
'{attribute} "{value}" has already been taken.' => '{attribute} با مقدار "{value}" در حال حاضر گرفتهشده است.',
74+
'{attribute} "{value}" has already been taken.' => '{attribute} در حال حاضر با مقدار "{value}" گرفته شده است.',
7575
'{attribute} cannot be blank.' => '{attribute} نمی‌تواند خالی باشد.',
76-
'{attribute} contains wrong subnet mask.' => '{attribute} شامل فرمت زیرشبکه اشتباه است.',
76+
'{attribute} contains wrong subnet mask.' => '{attribute} شامل فرمت پوشش زیرشبکه (subnet mask) اشتباه است.',
7777
'{attribute} is invalid.' => '{attribute} معتبر نیست.',
7878
'{attribute} is not a valid URL.' => '{attribute} یک URL معتبر نیست.',
7979
'{attribute} is not a valid email address.' => '{attribute} یک آدرس ایمیل معتبر نیست.',
@@ -82,17 +82,17 @@
8282
'{attribute} must be a number.' => '{attribute} باید یک عدد باشد.',
8383
'{attribute} must be a string.' => '{attribute} باید یک رشته باشد.',
8484
'{attribute} must be a valid IP address.' => '{attribute} باید یک آدرس IP معتبر باشد.',
85-
'{attribute} must be an IP address with specified subnet.' => '{attribute} باید یک IP آدرس با زیرشبکه بخصوص باشد.',
85+
'{attribute} must be an IP address with specified subnet.' => '{attribute} باید یک آدرس IP با زیرشبکه (subnet) مشخص شده باشد.',
8686
'{attribute} must be an integer.' => '{attribute} باید یک عدد صحیح باشد.',
8787
'{attribute} must be either "{true}" or "{false}".' => '{attribute} باید "{true}" و یا "{false}" باشد.',
8888
'{attribute} must be equal to "{compareValueOrAttribute}".' => '{attribute} باید با "{compareValueOrAttribute}" برابر باشد.',
89-
'{attribute} must be greater than "{compareValueOrAttribute}".' => '{attribute} باید بزرگتر از "{compareValueOrAttribute}" باشد.',
90-
'{attribute} must be greater than or equal to "{compareValueOrAttribute}".' => '{attribute} باید بزرگتر یا برابر با "{compareValueOrAttribute}" باشد.',
89+
'{attribute} must be greater than "{compareValueOrAttribute}".' => '{attribute} باید بیشتر از "{compareValueOrAttribute}" باشد.',
90+
'{attribute} must be greater than or equal to "{compareValueOrAttribute}".' => '{attribute} باید بیشتر یا برابر با "{compareValueOrAttribute}" باشد.',
9191
'{attribute} must be less than "{compareValueOrAttribute}".' => '{attribute} باید کمتر از "{compareValueOrAttribute}" باشد.',
9292
'{attribute} must be less than or equal to "{compareValueOrAttribute}".' => '{attribute} باید کمتر یا برابر با "{compareValueOrAttribute}" باشد.',
9393
'{attribute} must be no greater than {max}.' => '{attribute} نباید بیشتر از "{max}" باشد.',
9494
'{attribute} must be no less than {min}.' => '{attribute} نباید کمتر از "{min}" باشد.',
95-
'{attribute} must not be a subnet.' => '{attribute} نباید یک زیرشبکه باشد.',
95+
'{attribute} must not be a subnet.' => '{attribute} نباید یک زیرشبکه (subnet) باشد.',
9696
'{attribute} must not be an IPv4 address.' => '{attribute} نباید آدرس IPv4 باشد.',
9797
'{attribute} must not be an IPv6 address.' => '{attribute} نباید آدرس IPv6 باشد.',
9898
'{attribute} must not be equal to "{compareValueOrAttribute}".' => '{attribute} نباید برابر با "{compareValueOrAttribute}" باشد.',
@@ -114,14 +114,14 @@
114114
'{nFormatted} B' => '{nFormatted} B',
115115
'{nFormatted} GB' => '{nFormatted} GB',
116116
'{nFormatted} GiB' => '{nFormatted} GiB',
117-
'{nFormatted} kB' => '{nFormatted} kB',
118117
'{nFormatted} KiB' => '{nFormatted} KiB',
119118
'{nFormatted} MB' => '{nFormatted} MB',
120119
'{nFormatted} MiB' => '{nFormatted} MiB',
121120
'{nFormatted} PB' => '{nFormatted} PB',
122121
'{nFormatted} PiB' => '{nFormatted} PiB',
123122
'{nFormatted} TB' => '{nFormatted} TB',
124123
'{nFormatted} TiB' => '{nFormatted} TiB',
124+
'{nFormatted} kB' => '{nFormatted} kB',
125125
'{nFormatted} {n, plural, =1{byte} other{bytes}}' => '{nFormatted} بایت',
126126
'{nFormatted} {n, plural, =1{gibibyte} other{gibibytes}}' => '{nFormatted} گیبی‌بایت',
127127
'{nFormatted} {n, plural, =1{gigabyte} other{gigabytes}}' => '{nFormatted} گیگابایت',
@@ -133,4 +133,15 @@
133133
'{nFormatted} {n, plural, =1{petabyte} other{petabytes}}' => '{nFormatted} پتابایت',
134134
'{nFormatted} {n, plural, =1{tebibyte} other{tebibytes}}' => '{nFormatted} تبی‌بایت',
135135
'{nFormatted} {n, plural, =1{terabyte} other{terabytes}}' => '{nFormatted} ترابایت',
136+
'"{attribute}" does not support operator "{operator}".' => '"{attribute}" از عملگر "{operator}" پشتیبانی نمی‌کند.',
137+
'Action not found.' => 'عمل یافت نشد.',
138+
'Aliases available: {aliases}' => 'نام مستعارهای موجود: {aliases}',
139+
'Condition for "{attribute}" should be either a value or valid operator specification.' => 'شرط برای "{attribute}" باید یک مقدار یا مشخصه‌ی عملگر معتبر باشد.',
140+
'Operator "{operator}" must be used with a search attribute.' => 'عملگر "{operator}" باید با یک ویژگی جستجو استفاده شود.',
141+
'Operator "{operator}" requires multiple operands.' => 'عملگر "{operator}" به چند عملوند نیاز دارد.',
142+
'Options available: {options}' => 'گزینه‌های موجود: {options}',
143+
'The format of {filter} is invalid.' => 'قالب {filter} نامعتبر است.',
144+
'Unknown filter attribute "{attribute}"' => 'ویژگی "{attribute}" فیلتر ناشناخته',
145+
'You should upload at least {limit, number} {limit, plural, one{file} other{files}}.' => 'شما باید حداقل {limit, number} فایل آپلود کنید.',
146+
'{compareAttribute} is invalid.' => '{compareAttribute} نامعتبر است.',
136147
];

0 commit comments

Comments
 (0)