mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 13:09:53 +09:00
Update to laravel 7
This commit is contained in:
@@ -25,32 +25,36 @@ trait TranslatorTrait
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
public function setLocale(string $locale)
|
||||
{
|
||||
$this->locale = (string) $locale;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale ?: \Locale::getDefault();
|
||||
return $this->locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
|
||||
{
|
||||
$id = (string) $id;
|
||||
if (null === $id || '' === $id) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!isset($parameters['%count%']) || !is_numeric($parameters['%count%'])) {
|
||||
return strtr($id, $parameters);
|
||||
}
|
||||
|
||||
$number = (float) $parameters['%count%'];
|
||||
$locale = (string) $locale ?: $this->getLocale();
|
||||
$locale = $locale ?: $this->getLocale();
|
||||
|
||||
$parts = [];
|
||||
if (preg_match('/^\|++$/', $id)) {
|
||||
@@ -90,8 +94,8 @@ EOF;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$leftNumber = '-Inf' === $matches['left'] ? -INF : (float) $matches['left'];
|
||||
$rightNumber = \is_numeric($matches['right']) ? (float) $matches['right'] : INF;
|
||||
$leftNumber = '-Inf' === $matches['left'] ? -\INF : (float) $matches['left'];
|
||||
$rightNumber = is_numeric($matches['right']) ? (float) $matches['right'] : \INF;
|
||||
|
||||
if (('[' === $matches['left_delimiter'] ? $number >= $leftNumber : $number > $leftNumber)
|
||||
&& (']' === $matches['right_delimiter'] ? $number <= $rightNumber : $number < $rightNumber)
|
||||
@@ -117,7 +121,7 @@ EOF;
|
||||
|
||||
$message = sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number);
|
||||
|
||||
if (\class_exists(InvalidArgumentException::class)) {
|
||||
if (class_exists(InvalidArgumentException::class)) {
|
||||
throw new InvalidArgumentException($message);
|
||||
}
|
||||
|
||||
@@ -134,9 +138,11 @@ EOF;
|
||||
* which is subject to the new BSD license (http://framework.zend.com/license/new-bsd).
|
||||
* Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
*/
|
||||
private function getPluralizationRule(int $number, string $locale): int
|
||||
private function getPluralizationRule(float $number, string $locale): int
|
||||
{
|
||||
switch ('pt_BR' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
|
||||
$number = abs($number);
|
||||
|
||||
switch ('pt_BR' !== $locale && 'en_US_POSIX' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
|
||||
case 'af':
|
||||
case 'bn':
|
||||
case 'bg':
|
||||
@@ -145,6 +151,7 @@ EOF;
|
||||
case 'de':
|
||||
case 'el':
|
||||
case 'en':
|
||||
case 'en_US_POSIX':
|
||||
case 'eo':
|
||||
case 'es':
|
||||
case 'et':
|
||||
@@ -203,7 +210,7 @@ EOF;
|
||||
case 'pt_BR':
|
||||
case 'ti':
|
||||
case 'wa':
|
||||
return ((0 == $number) || (1 == $number)) ? 0 : 1;
|
||||
return ($number < 2) ? 0 : 1;
|
||||
|
||||
case 'be':
|
||||
case 'bs':
|
||||
|
||||
Reference in New Issue
Block a user