Merge branch 'master' into bugfix/20002-Superfluous_query_on_HEAD_request_in_serializer

This commit is contained in:
Alexander Makarov
2023-10-19 20:36:05 +03:00
committed by GitHub
2 changed files with 52 additions and 31 deletions

View File

@ -97,22 +97,13 @@ class BaseFormatConverter
* @param string|null $locale the locale to use for converting ICU short patterns `short`, `medium`, `long` and `full`.
* If not given, `Yii::$app->language` will be used.
* @return string The converted date format pattern.
* @throws \Exception
*/
public static function convertDateIcuToPhp($pattern, $type = 'date', $locale = null)
{
if (isset(self::$_icuShortFormats[$pattern])) {
if (extension_loaded('intl')) {
if ($locale === null) {
$locale = Yii::$app->language;
}
if ($type === 'date') {
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], IntlDateFormatter::NONE);
} elseif ($type === 'time') {
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::NONE, self::$_icuShortFormats[$pattern]);
} else {
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], self::$_icuShortFormats[$pattern]);
}
$pattern = $formatter->getPattern();
$pattern = static::createFormatter($locale, $type, $pattern);
} else {
return static::$phpFallbackDatePatterns[$pattern][$type];
}
@ -350,22 +341,13 @@ class BaseFormatConverter
* @param string|null $locale the locale to use for converting ICU short patterns `short`, `medium`, `long` and `full`.
* If not given, `Yii::$app->language` will be used.
* @return string The converted date format pattern.
* @throws \Exception
*/
public static function convertDateIcuToJui($pattern, $type = 'date', $locale = null)
{
if (isset(self::$_icuShortFormats[$pattern])) {
if (extension_loaded('intl')) {
if ($locale === null) {
$locale = Yii::$app->language;
}
if ($type === 'date') {
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], IntlDateFormatter::NONE);
} elseif ($type === 'time') {
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::NONE, self::$_icuShortFormats[$pattern]);
} else {
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], self::$_icuShortFormats[$pattern]);
}
$pattern = $formatter->getPattern();
$pattern = static::createFormatter($locale, $type, $pattern);
} else {
return static::$juiFallbackDatePatterns[$pattern][$type];
}
@ -545,4 +527,32 @@ class BaseFormatConverter
'U' => '@', // Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
]);
}
/**
* Creates a date/time formatter based on the given parameters.
*
* @param string|null $locale The locale to be used. If null, the application's current language will be used.
* @param string $type The type of formatter ('date', 'time', etc.)
* @param string $pattern The pattern for the IntlDateFormatter.
*
* @return string The resulting pattern after formatter creation.
*
* @throws \Exception If the 'intl' extension is not loaded.
*/
private static function createFormatter($locale, $type, $pattern)
{
if ($locale === null) {
$locale = Yii::$app->language;
}
if ($type === 'date') {
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], IntlDateFormatter::NONE);
} elseif ($type === 'time') {
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::NONE, self::$_icuShortFormats[$pattern]);
} else {
$formatter = new IntlDateFormatter($locale, self::$_icuShortFormats[$pattern], self::$_icuShortFormats[$pattern]);
}
return $formatter->getPattern();
}
}

View File

@ -45,8 +45,8 @@ return [
'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> مورد.',
'The combination {values} of {attributes} has already been taken.' => 'مقدار {values} از {attributes} قبلاً گرفته شده است.',
'The file "{file}" is not an image.' => 'فایل "{file}" یک تصویر نیست.',
'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => 'حجم فایل "{file}" بسیار بیشتر می باشد. حجم آن نمی تواند از {formattedLimit} بیشتر باشد.',
'The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}.' => 'حجم فایل "{file}" بسیار کم می باشد. حجم آن نمی تواند از {formattedLimit} کمتر باشد.',
'The file "{file}" is too big. Its size cannot exceed {formattedLimit}.' => 'حجم فایل "{file}" بسیار بیشتر میباشد. حجم آن نمیتواند از {formattedLimit} بیشتر باشد.',
'The file "{file}" is too small. Its size cannot be smaller than {formattedLimit}.' => 'حجم فایل "{file}" بسیار کم میباشد. حجم آننمی تواند از {formattedLimit} کمتر باشد.',
'The format of {attribute} is invalid.' => 'قالب {attribute} نامعتبر است.',
'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'تصویر "{file}" خیلی بزرگ است. ارتفاع نمی‌تواند بزرگتر از {limit, number} پیکسل باشد.',
'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 @@ return [
'in {delta, plural, =1{an hour} other{# hours}}' => '{delta} ساعت دیگر',
'just now' => 'هم اکنون',
'the input value' => 'مقدار ورودی',
'{attribute} "{value}" has already been taken.' => '{attribute} با مقدار "{value}" در حال حاضر گرفتهشده است.',
'{attribute} "{value}" has already been taken.' => '{attribute} در حال حاضر با مقدار "{value}" گرفته شده است.',
'{attribute} cannot be blank.' => '{attribute} نمی‌تواند خالی باشد.',
'{attribute} contains wrong subnet mask.' => '{attribute} شامل فرمت زیرشبکه اشتباه است.',
'{attribute} contains wrong subnet mask.' => '{attribute} شامل فرمت پوشش زیرشبکه (subnet mask) اشتباه است.',
'{attribute} is invalid.' => '{attribute} معتبر نیست.',
'{attribute} is not a valid URL.' => '{attribute} یک URL معتبر نیست.',
'{attribute} is not a valid email address.' => '{attribute} یک آدرس ایمیل معتبر نیست.',
@ -82,17 +82,17 @@ return [
'{attribute} must be a number.' => '{attribute} باید یک عدد باشد.',
'{attribute} must be a string.' => '{attribute} باید یک رشته باشد.',
'{attribute} must be a valid IP address.' => '{attribute} باید یک آدرس IP معتبر باشد.',
'{attribute} must be an IP address with specified subnet.' => '{attribute} باید یک IP آدرس با زیرشبکه بخصوص باشد.',
'{attribute} must be an IP address with specified subnet.' => '{attribute} باید یک آدرس IP با زیرشبکه (subnet) مشخص شده باشد.',
'{attribute} must be an integer.' => '{attribute} باید یک عدد صحیح باشد.',
'{attribute} must be either "{true}" or "{false}".' => '{attribute} باید "{true}" و یا "{false}" باشد.',
'{attribute} must be equal to "{compareValueOrAttribute}".' => '{attribute} باید با "{compareValueOrAttribute}" برابر باشد.',
'{attribute} must be greater than "{compareValueOrAttribute}".' => '{attribute} باید بزرگتر از "{compareValueOrAttribute}" باشد.',
'{attribute} must be greater than or equal to "{compareValueOrAttribute}".' => '{attribute} باید بزرگتر یا برابر با "{compareValueOrAttribute}" باشد.',
'{attribute} must be greater than "{compareValueOrAttribute}".' => '{attribute} باید بیشتر از "{compareValueOrAttribute}" باشد.',
'{attribute} must be greater than or equal to "{compareValueOrAttribute}".' => '{attribute} باید بیشتر یا برابر با "{compareValueOrAttribute}" باشد.',
'{attribute} must be less than "{compareValueOrAttribute}".' => '{attribute} باید کمتر از "{compareValueOrAttribute}" باشد.',
'{attribute} must be less than or equal to "{compareValueOrAttribute}".' => '{attribute} باید کمتر یا برابر با "{compareValueOrAttribute}" باشد.',
'{attribute} must be no greater than {max}.' => '{attribute} نباید بیشتر از "{max}" باشد.',
'{attribute} must be no less than {min}.' => '{attribute} نباید کمتر از "{min}" باشد.',
'{attribute} must not be a subnet.' => '{attribute} نباید یک زیرشبکه باشد.',
'{attribute} must not be a subnet.' => '{attribute} نباید یک زیرشبکه (subnet) باشد.',
'{attribute} must not be an IPv4 address.' => '{attribute} نباید آدرس IPv4 باشد.',
'{attribute} must not be an IPv6 address.' => '{attribute} نباید آدرس IPv6 باشد.',
'{attribute} must not be equal to "{compareValueOrAttribute}".' => '{attribute} نباید برابر با "{compareValueOrAttribute}" باشد.',
@ -114,7 +114,6 @@ return [
'{nFormatted} B' => '{nFormatted} B',
'{nFormatted} GB' => '{nFormatted} GB',
'{nFormatted} GiB' => '{nFormatted} GiB',
'{nFormatted} kB' => '{nFormatted} kB',
'{nFormatted} KiB' => '{nFormatted} KiB',
'{nFormatted} MB' => '{nFormatted} MB',
'{nFormatted} MiB' => '{nFormatted} MiB',
@ -122,6 +121,7 @@ return [
'{nFormatted} PiB' => '{nFormatted} PiB',
'{nFormatted} TB' => '{nFormatted} TB',
'{nFormatted} TiB' => '{nFormatted} TiB',
'{nFormatted} kB' => '{nFormatted} kB',
'{nFormatted} {n, plural, =1{byte} other{bytes}}' => '{nFormatted} بایت',
'{nFormatted} {n, plural, =1{gibibyte} other{gibibytes}}' => '{nFormatted} گیبی‌بایت',
'{nFormatted} {n, plural, =1{gigabyte} other{gigabytes}}' => '{nFormatted} گیگابایت',
@ -133,4 +133,15 @@ return [
'{nFormatted} {n, plural, =1{petabyte} other{petabytes}}' => '{nFormatted} پتابایت',
'{nFormatted} {n, plural, =1{tebibyte} other{tebibytes}}' => '{nFormatted} تبی‌بایت',
'{nFormatted} {n, plural, =1{terabyte} other{terabytes}}' => '{nFormatted} ترابایت',
'"{attribute}" does not support operator "{operator}".' => '"{attribute}" از عملگر "{operator}" پشتیبانی نمی‌کند.',
'Action not found.' => 'عمل یافت نشد.',
'Aliases available: {aliases}' => 'نام مستعارهای موجود: {aliases}',
'Condition for "{attribute}" should be either a value or valid operator specification.' => 'شرط برای "{attribute}" باید یک مقدار یا مشخصه‌ی عملگر معتبر باشد.',
'Operator "{operator}" must be used with a search attribute.' => 'عملگر "{operator}" باید با یک ویژگی جستجو استفاده شود.',
'Operator "{operator}" requires multiple operands.' => 'عملگر "{operator}" به چند عملوند نیاز دارد.',
'Options available: {options}' => 'گزینه‌های موجود: {options}',
'The format of {filter} is invalid.' => 'قالب {filter} نامعتبر است.',
'Unknown filter attribute "{attribute}"' => 'ویژگی "{attribute}" فیلتر ناشناخته',
'You should upload at least {limit, number} {limit, plural, one{file} other{files}}.' => 'شما باید حداقل {limit, number} فایل آپلود کنید.',
'{compareAttribute} is invalid.' => '{compareAttribute} نامعتبر است.',
];