8000 Merge branch '3.4' into 4.3 · symfony/symfony@af4f99f · GitHub
[go: up one dir, main page]

Skip to content

Commit af4f99f

Browse files
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
2 parents 8855082 + 7aba9cf commit af4f99f

File tree

9 files changed

+145
-19
lines changed

9 files changed

+145
-19
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/info.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'no_token' : {
55
status: 'error',
66
title: (token|default('') == 'latest') ? 'There are no profiles' : 'Token not found',
7-
message: (token|default('') == 'latest') ? 'No profiles found in the database.' : 'Token "' ~ token|default('') ~ '" was not found in the database.'
7+
message: (token|default('') == 'latest') ? 'No profiles found.' : 'Token "' ~ token|default('') ~ '" not found.'
88
}
99
} %}
1010

src/Symfony/Component/Console/Application.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,13 @@ public function find($name)
663663
// filter out aliases for commands which are already on the list
664664
if (\count($commands) > 1) {
665665
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
666-
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
667-
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
666+
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
667+
if (!$commandList[$nameOrAlias] instanceof Command) {
668+
$commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
669+
}
670+
671+
$commandName = $commandList[$nameOrAlias]->getName();
672+
668673
$aliases[$nameOrAlias] = $commandName;
669674

670675
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
@@ -680,10 +685,6 @@ public function find($name)
680685
$maxLen = max(Helper::strlen($abbrev), $maxLen);
681686
}
682687
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen) {
683-
if (!$commandList[$cmd] instanceof Command) {
684-
$commandList[$cmd] = $this->commandLoader->get($cmd);
685-
}
686-
687688
if ($commandList[$cmd]->isHidden()) {
688689
return false;
689690
}

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ public function testFindAlternativeCommandsWithAnAlias()
615615
$fooCommand->setAliases(['foo2']);
616616

617617
$application = new Application();
618+
$application->setCommandLoader(new FactoryCommandLoader([
619+
'foo3' => static function () use ($fooCommand) { return $fooCommand; },
620+
]));
618621
$application->add($fooCommand);
619622

620623
$result = $application F438 ->find('foo');

src/Symfony/Component/Dotenv/Tests/DotenvTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,13 @@ public function testGetVariablesValueFromGetenv()
436436
putenv('Foo=Bar');
437437

438438
$dotenv = new Dotenv(true);
439-
$values = $dotenv->parse('Foo=${Foo}');
440-
$this->assertSame('Bar', $values['Foo']);
441439

442-
putenv('Foo');
440+
try {
441+
$values = $dotenv->parse('Foo=${Foo}');
442+
$this->assertSame('Bar', $values['Foo']);
443+
} finally {
444+
putenv('Foo');
445+
}
443446
}
444447

445448
/**

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function prepare(Request $request)
217217
}
218218
if ('x-accel-redirect' === strtolower($type)) {
219219
// Do X-Accel-Mapping substitutions.
220-
// @link http://wiki.nginx.org/X-accel#X-Accel-Redirect
220+
// @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect
221221
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
222222
foreach ($parts as $part) {
223223
list($pathPrefix, $location) = $part;

src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
1717
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
1818
use Symfony\Component\Translation\DataCollectorTranslator;
19+
use Symfony\Component\VarDumper\Cloner\Data;
1920

2021
/**
2122
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>

src/Symfony/Component/Translation/Tests/TranslatorTest.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,38 @@ public function testTransWithIcuRootFallbackLocale()
270270
$this->assertSame('bar', $translator->trans('bar'));
271271
}
272272

273-
public function testTransWithFallbackLocaleBis()
273+
/**
274+
* @dataProvider getFallbackLocales
275+
*/
276+
public function testTransWithFallbackLocaleBis($expectedLocale, $locale)
274277
{
275-
$translator = new Translator('en_US');
278+
$translator = new Translator($locale);
276279
$translator->addLoader('array', new ArrayLoader());
277-
$translator->addResource('array', ['foo' => 'foofoo'], 'en_US');
278-
$translator->addResource('array', ['bar' => 'foobar'], 'en');
280+
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
281+
$translator->addResource('array', ['bar' => 'foobar'], $expectedLocale);
279282
$this->assertEquals('foobar', $translator->trans('bar'));
280283
}
281284

285+
public function getFallbackLocales()
286+
{
287+
$locales = [
288+
['en', 'en_US'],
289+
['en', 'en-US'],
290+
['sl_Latn_IT', 'sl_Latn_IT_nedis'],
291+
['sl_Latn', 'sl_Latn_IT'],
292+
];
293+
294+
if (\function_exists('locale_parse')) {
295+
$locales[] = ['sl_Latn_IT', 'sl-Latn-IT-nedis'];
296+
$locales[] = ['sl_Latn', 'sl-Latn-IT'];
297+
} else {
298+
$locales[] = ['sl-Latn-IT', 'sl-Latn-IT-nedis'];
299+
$locales[] = ['sl-Latn', 'sl-Latn-IT'];
300+
}
301+
302+
return $locales;
303+
}
304+
282305
public function testTransWithFallbackLocaleTer()
283306
{
284307
$translator = new Translator('fr_FR');

src/Symfony/Component/Translation/Translator.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,17 @@ protected function computeFallbackLocales($locale)
451451
while ($locale) {
452452
$parent = $parentLocales[$locale] ?? null;
453453

454-
if (!$parent && false !== strrchr($locale, '_')) {
455-
$locale = substr($locale, 0, -\strlen(strrchr($locale, '_')));
456-
} elseif ('root' !== $parent) {
457-
$locale = $parent;
454+
if ($parent) {
455+
$locale = 'root' !== $parent ? $parent : null;
456+
} elseif (\function_exists('locale_parse')) {
457+
$localeSubTags = locale_parse($locale);
458+
$locale = null;
459+
if (1 < \count($localeSubTags)) {
460+
array_pop($localeSubTags);
461+
$locale = locale_compose($localeSubTags) ?: null;
462+
}
463+
} elseif ($i = strrpos($locale, '_') ?: strrpos($locale, '-')) {
464+
$locale = substr($locale, 0, $i);
458465
} else {
459466
$locale = null;
460467
}

src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,94 @@
278278
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
279279
<target>該值不應與 {{ compared_value_type }} {{ compared_value }} 相同。</target>
280280
</trans-unit>
281+
<trans-unit id="73">
282+
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
283+
<target>圖像格式過大 ({{ ratio }})。 最大允許尺寸 {{ max_ratio }}。</target>
284+
</trans-unit>
285+
<trans-unit id="74">
286+
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
287+
<target>圖像格式過小 ({{ ratio }})。最小尺寸 {{ min_ratio }}。</target>
288+
</trans-unit>
289+
<trans-unit id="75">
290+
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
291+
<target>方形圖像 ({{ width }}x{{ height }}px)。不接受方形圖像。</target>
292+
</trans-unit>
293+
<trans-unit id="76">
294+
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
295+
<target>紀念冊布局圖像 ({{ width }}x{{ height }}px)。 不接受紀念冊布局圖像。</target>
296+
</trans-unit>
297+
<trans-unit id="77">
298+
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
299+
<target>書籍布局圖像 ({{ width }}x{{ height }}px)。不接受圖像書籍布局。</target>
300+
</trans-unit>
301+
<trans-unit id="78">
302+
<source>An empty file is not allowed.</source>
303+
<target>不接受空白文件。</target>
304+
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>未找到服務器。</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>該數值不符合預期 {{ charset }} 符號編碼。</target>
312+
</trans-unit>
313+
<trans-unit id="81">
314+
<source>This is not a valid Business Identifier Code (BIC).</source>
315+
<target>無效企業識別碼 (BIC)。</target>
316+
</trans-unit>
317+
<trans-unit id="82">
318+
<source>Error.</source>
319+
<target>錯誤。</target>
320+
</trans-unit>
321+
<trans-unit id="83">
322+
<source>This is not F438 a valid UUID.</source>
323+
<target>無效的通用唯壹標識符 (UUID)。</target>
324+
</trans-unit>
325+
<trans-unit id="84">
326+
<source>This value should be a multiple of {{ compared_value }}.</source>
327+
<target>該值必須是倍數 {{ compared_value }}。</target>
328+
</trans-unit>
329+
<trans-unit id="85">
330+
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331+
<target>該企業識別碼 (BIC) 與銀行賬戶國際編號不壹致 (IBAN) {{ iban }}。</target>
332+
</trans-unit>
333+
<trans-unit id="86">
334+
<source>This value should be valid JSON.</source>
335+
<target>該數值必須序列化為JSON格式。</target>
336+
</trans-unit>
337+
<trans-unit id="87">
338+
<source>This collection should contain only unique elements.</source>
339+
<target>該集合應僅包含唯壹元素。</target>
340+
</trans-unit>
341+
<trans-unit id="88">
342+
<source>This value should be positive.</source>
343+
<target>數值應為正數。</target>
344+
</trans-unit>
345+
<trans-unit id="89">
346+
<source>This value should be either positive or zero.</source>
347+
<target>數值應或未正數,或為零。</target>
348+
</trans-unit>
349+
<trans-unit id="90">
350+
<source>This value should be negative.</source>
351+
<target>數值應為負數。</target>
352+
</trans-unit>
353+
<trans-unit id="91">
354+
<source>This value should be either negative or zero.</source>
355+
<target>數值應或未負數,或為零。</target>
356+
</trans-unit>
357+
<trans-unit id="92">
358+
<source>This value is not a valid timezone.</source>
359+
<target>無效時區。</target>
360+
</trans-unit>
361+
<trans-unit id="93">
362+
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363+
<target>依據您的密碼,發生數據泄露,請勿使用改密碼。請更換密碼。</target>
364+
</trans-unit>
365+
<trans-unit id="94">
366+
<source>This value should be between {{ min }} and {{ max }}.</source>
367+
<target>該數值應在 {{ min }} 和 {{ max }} 之間。</target>
368+
</trans-unit>
281369
</body>
282370
</file>
283371
</xliff>

0 commit comments

Comments
 (0)
0