Merge branch '3.4' into 4.3

* 3.4:
  Add missing use statement
  [Profiler] wording
  X-Accel Nginx URL updated
  ticket-30197 [Validator] Add the missing translations for the Chinese (Taiwan) ("zh_TW") locale
  Fixed test added in #35022
  Use locale_parse for computing fallback locales
  [Console] Fix filtering out identical alternatives when there is a command loader
This commit is contained in:
Nicolas Grekas 2019-12-28 15:48:01 +01:00
commit af4f99f52b
9 changed files with 145 additions and 19 deletions

View File

@ -4,7 +4,7 @@
'no_token' : {
status: 'error',
title: (token|default('') == 'latest') ? 'There are no profiles' : 'Token not found',
message: (token|default('') == 'latest') ? 'No profiles found in the database.' : 'Token "' ~ token|default('') ~ '" was not found in the database.'
message: (token|default('') == 'latest') ? 'No profiles found.' : 'Token "' ~ token|default('') ~ '" not found.'
}
} %}

View File

@ -663,8 +663,13 @@ class Application
// filter out aliases for commands which are already on the list
if (\count($commands) > 1) {
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
if (!$commandList[$nameOrAlias] instanceof Command) {
$commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
}
$commandName = $commandList[$nameOrAlias]->getName();
$aliases[$nameOrAlias] = $commandName;
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
@ -680,10 +685,6 @@ class Application
$maxLen = max(Helper::strlen($abbrev), $maxLen);
}
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen) {
if (!$commandList[$cmd] instanceof Command) {
$commandList[$cmd] = $this->commandLoader->get($cmd);
}
if ($commandList[$cmd]->isHidden()) {
return false;
}

View File

@ -615,6 +615,9 @@ class ApplicationTest extends TestCase
$fooCommand->setAliases(['foo2']);
$application = new Application();
$application->setCommandLoader(new FactoryCommandLoader([
'foo3' => static function () use ($fooCommand) { return $fooCommand; },
]));
$application->add($fooCommand);
$result = $application->find('foo');

View File

@ -436,10 +436,13 @@ class DotenvTest extends TestCase
putenv('Foo=Bar');
$dotenv = new Dotenv(true);
$values = $dotenv->parse('Foo=${Foo}');
$this->assertSame('Bar', $values['Foo']);
putenv('Foo');
try {
$values = $dotenv->parse('Foo=${Foo}');
$this->assertSame('Bar', $values['Foo']);
} finally {
putenv('Foo');
}
}
/**

View File

@ -217,7 +217,7 @@ class BinaryFileResponse extends Response
}
if ('x-accel-redirect' === strtolower($type)) {
// Do X-Accel-Mapping substitutions.
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
// @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
foreach ($parts as $part) {
list($pathPrefix, $location) = $part;

View File

@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
use Symfony\Component\Translation\DataCollectorTranslator;
use Symfony\Component\VarDumper\Cloner\Data;
/**
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>

View File

@ -270,15 +270,38 @@ class TranslatorTest extends TestCase
$this->assertSame('bar', $translator->trans('bar'));
}
public function testTransWithFallbackLocaleBis()
/**
* @dataProvider getFallbackLocales
*/
public function testTransWithFallbackLocaleBis($expectedLocale, $locale)
{
$translator = new Translator('en_US');
$translator = new Translator($locale);
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', ['foo' => 'foofoo'], 'en_US');
$translator->addResource('array', ['bar' => 'foobar'], 'en');
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
$translator->addResource('array', ['bar' => 'foobar'], $expectedLocale);
$this->assertEquals('foobar', $translator->trans('bar'));
}
public function getFallbackLocales()
{
$locales = [
['en', 'en_US'],
['en', 'en-US'],
['sl_Latn_IT', 'sl_Latn_IT_nedis'],
['sl_Latn', 'sl_Latn_IT'],
];
if (\function_exists('locale_parse')) {
$locales[] = ['sl_Latn_IT', 'sl-Latn-IT-nedis'];
$locales[] = ['sl_Latn', 'sl-Latn-IT'];
} else {
$locales[] = ['sl-Latn-IT', 'sl-Latn-IT-nedis'];
$locales[] = ['sl-Latn', 'sl-Latn-IT'];
}
return $locales;
}
public function testTransWithFallbackLocaleTer()
{
$translator = new Translator('fr_FR');

View File

@ -451,10 +451,17 @@ EOF
while ($locale) {
$parent = $parentLocales[$locale] ?? null;
if (!$parent && false !== strrchr($locale, '_')) {
$locale = substr($locale, 0, -\strlen(strrchr($locale, '_')));
} elseif ('root' !== $parent) {
$locale = $parent;
if ($parent) {
$locale = 'root' !== $parent ? $parent : null;
} elseif (\function_exists('locale_parse')) {
$localeSubTags = locale_parse($locale);
$locale = null;
if (1 < \count($localeSubTags)) {
array_pop($localeSubTags);
$locale = locale_compose($localeSubTags) ?: null;
}
} elseif ($i = strrpos($locale, '_') ?: strrpos($locale, '-')) {
$locale = substr($locale, 0, $i);
} else {
$locale = null;
}

View File

@ -278,6 +278,94 @@
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>該值不應與 {{ compared_value_type }} {{ compared_value }} 相同。</target>
</trans-unit>
<trans-unit id="73">
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
<target>圖像格式過大 ({{ ratio }})。 最大允許尺寸 {{ max_ratio }}。</target>
</trans-unit>
<trans-unit id="74">
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
<target>圖像格式過小 ({{ ratio }})。最小尺寸 {{ min_ratio }}。</target>
</trans-unit>
<trans-unit id="75">
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
<target>方形圖像 ({{ width }}x{{ height }}px)。不接受方形圖像。</target>
</trans-unit>
<trans-unit id="76">
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
<target>紀念冊布局圖像 ({{ width }}x{{ height }}px)。 不接受紀念冊布局圖像。</target>
</trans-unit>
<trans-unit id="77">
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>書籍布局圖像 ({{ width }}x{{ height }}px)。不接受圖像書籍布局。</target>
</trans-unit>
<trans-unit id="78">
<source>An empty file is not allowed.</source>
<target>不接受空白文件。</target>
</trans-unit>
<trans-unit id="79">
<source>The host could not be resolved.</source>
<target>未找到服務器。</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>該數值不符合預期 {{ charset }} 符號編碼。</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<target>無效企業識別碼 (BIC)。</target>
</trans-unit>
<trans-unit id="82">
<source>Error.</source>
<target>錯誤。</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<target>無效的通用唯壹標識符 (UUID)。</target>
</trans-unit>
<trans-unit id="84">
<source>This value should be a multiple of {{ compared_value }}.</source>
<target>該值必須是倍數 {{ compared_value }}。</target>
</trans-unit>
<trans-unit id="85">
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
<target>該企業識別碼 (BIC) 與銀行賬戶國際編號不壹致 (IBAN) {{ iban }}。</target>
</trans-unit>
<trans-unit id="86">
<source>This value should be valid JSON.</source>
<target>該數值必須序列化為JSON格式。</target>
</trans-unit>
<trans-unit id="87">
<source>This collection should contain only unique elements.</source>
<target>該集合應僅包含唯壹元素。</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>數值應為正數。</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>數值應或未正數,或為零。</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be negative.</source>
<target>數值應為負數。</target>
</trans-unit>
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>數值應或未負數,或為零。</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>無效時區。</target>
</trans-unit>
<trans-unit id="93">
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>依據您的密碼,發生數據泄露,請勿使用改密碼。請更換密碼。</target>
</trans-unit>
<trans-unit id="94">
<source>This value should be between {{ min }} and {{ max }}.</source>
<target>該數值應在 {{ min }} 和 {{ max }} 之間。</target>
</trans-unit>
</body>
</file>
</xliff>