10000 Merge branch '3.4' into 4.3 · Simperfit/symfony@7bb421b · GitHub
[go: up one dir, main page]

Skip to content

Commit 7bb421b

Browse files
Merge branch '3.4' into 4.3
* 3.4: [Form][Validator][Intl] Fix tests [Validator] Accept underscores in the URL validator as the URL will resolve correctly [Translation] Collect original locale in case of fallback translation Fix toolbar load when GET params are present in "_wdt" route
2 parents abf11d8 + 82a62d2 commit 7bb421b

File tree

8 files changed

+26
-17
lines changed

8 files changed

+26
-17
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
{% set text %}
1515
<div class="sf-toolbar-info-piece">
16-
<b>Locale</b>
16+
<b>Default locale</b>
1717
<span class="sf-toolbar-status">
1818
{{ collector.locale|default('-') }}
1919
</span>
@@ -61,7 +61,7 @@
6161
<div class="metrics">
6262
<div class="metric">
6363
<span class="value">{{ collector.locale|default('-') }}</span>
64-
<span class="label">Locale</span>
64+
<span class="label">Default locale</span>
6565
</div>
6666
<div class="metric">
6767
<span class="value">{{ collector.fallbackLocales|join(', ')|default('-') }}</span>
@@ -126,7 +126,7 @@
126126
</div>
127127
{% else %}
128128
{% block fallback_messages %}
129-
{{ helper.render_table(messages_fallback) }}
129+
{{ helper.render_table(messages_fallback, true) }}
130130
{% endblock %}
131131
{% endif %}
132132
</div>
@@ -162,11 +162,14 @@
162162

163163
{% endblock %}
164164

165-
{% macro render_table(messages) %}
165+
{% macro render_table(messages, is_fallback) %}
166166
<table data-filters>
167167
<thead>
168168
<tr>
169169
<th data-filter="locale">Locale</th>
170+
{% if is_fallback %}
171+
<th>Fallback locale</th>
172+
{% endif %}
170173
<th data-filter="domain">Domain</th>
171174
<th>Times used</th>
172175
<th>Message ID</th>
@@ -177,6 +180,9 @@
177180
{% for message in messages %}
178181
<tr data-filter-locale="{{ message.locale }}" data-filter-domain="{{ message.domain }}">
179182
<td class="font-normal text-small nowrap">{{ message.locale }}</td>
183+
{% if is_fallback %}
184+
<td class="font-normal text-small nowrap">{{ message.fallbackLocale|default('-') }}</td>
185+
{% endif %}
180186
<td class="font-normal text-small text-bold nowrap">{{ message.domain }}</td>
181187
<td class="font-normal text-small nowrap">{{ message.count }}</td>
182188
<td>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
newToken = (newToken || token);
423423
this.load(
424424
'sfwdt' + token,
425-
'{{ path("_wdt", { "token": "xxxxxx" }) }}'.replace(/xxxxxx/, newToken),
425+
'{{ path("_wdt", { "token": "xxxxxx" })|escape('js') }}'.replace(/xxxxxx/, newToken),
426426
function(xhr, el) {
427427
428428
/* Evaluate in global scope scripts embedded inside the toolbar */
@@ -525,7 +525,7 @@
525525
sfwdt.innerHTML = '\
526526
<div class="sf-toolbarreset">\
527527
<div class="sf-toolbar-icon"><svg width="26" height="28" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 26 28" enable-background="new 0 0 26 28" xml:space="preserve"><path fill="#FFFFFF" d="M13 0C5.8 0 0 5.8 0 13c0 7.2 5.8 13 13 13c7.2 0 13-5.8 13-13C26 5.8 20.2 0 13 0z M20 7.5 c-0.6 0-1-0.3-1-0.9c0-0.2 0-0.4 0.2-0.6c0.1-0.3 0.2-0.3 0.2-0.4c0-0.3-0.5-0.4-0.7-0.4c-2 0.1-2.5 2.7-2.9 4.8l-0.2 1.1 c1.1 0.2 1.9 0 2.4-0.3c0.6-0.4-0.2-0.8-0.1-1.3C18 9.2 18.4 9 18.7 8.9c0.5 0 0.8 0.5 0.8 1c0 0.8-1.1 2-3.3 1.9 c-0.3 0-0.5 0-0.7-0.1L15 14.1c-0.4 1.7-0.9 4.1-2.6 6.2c-1.5 1.8-3.1 2.1-3.8 2.1c-1.3 0-2.1-0.6-2.2-1.6c0-0.9 0.8-1.4 1.3-1.4 c0.7 0 1.2 0.5 1.2 1.1c0 0.5-0.2 0.6-0.4 0.7c-0.1 0.1-0.3 0.2-0.3 0.4c0 0.1 0.1 0.3 0.4 0.3c0.5 0 0.9-0.3 1.2-0.5 c1.3-1 1.7-2.9 2.4-6.2l0.1-0.8c0.2-1.1 0.5-2.3 0.8-3.5c-0.9-0.7-1.4-1.5-2.6-1.8c-0.8-0.2-1.3 0-1.7 0.4C8.4 10 8.6 10.7 9 11.1 l0.7 0.7c0.8 0.9 1.3 1.7 1.1 2.7c-0.3 1.6-2.1 2.8-4.3 2.1c-1.9-0.6-2.2-1.9-2-2.7c0.2-0.6 0.7-0.8 1.2-0.6 c0.5 0.2 0.7 0.8 0.6 1.3c0 0.1 0 0.1-0.1 0.3C6 15 5.9 15.2 5.9 15.3c-0.1 0.4 0.4 0.7 0.8 0.8c0.8 0.3 1.7-0.2 1.9-0.9 c0.2-0.6-0.2-1.1-0.4-1.2l-0.8-0.9c-0.4-0.4-1.2-1.5-0.8-2.8c0.2-0.5 0.5-1 0.9-1.4c1-0.7 2-0.8 3-0.6c1.3 0.4 1.9 1.2 2.8 1.9 c0.5-1.3 1.1-2.6 2-3.8c0.9-1 2-1.7 3.3-1.8C20 4.8 21 5.4 21 6.3C21 6.7 20.8 7.5 20 7.5z"/></svg></div>\
528-
An error occurred while loading the web debug toolbar. <a href="{{ path("_profiler_home") }}' + newToken + '>Open the web profiler.</a>\
528+
An error occurred while loading the web debug toolbar. <a href="{{ path("_profiler_home")|escape('js') }}' + newToken + '>Open the web profiler.</a>\
529529
</div>\
530530
';
531531
sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar');

src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public function testCountriesAreSelectable()
3232
->createView()->vars['choices'];
3333

3434
$this->assertContainsEquals(new ChoiceView('en', 'en', 'English'), $choices);
35-
$this->assertContainsEquals(new ChoiceView('en_GB', 'en_GB', 'British English'), $choices);
36-
$this->assertContainsEquals(new ChoiceView('en_US', 'en_US', 'American English'), $choices);
3735
$this->assertContainsEquals(new ChoiceView('fr', 'fr', 'French'), $choices);
3836
$this->assertContainsEquals(new ChoiceView('my', 'my', 'Burmese'), $choices);
3937
}
@@ -51,7 +49,6 @@ public function testChoiceTranslationLocaleOption()
5149

5250
// Don't check objects for identity
5351
$this->assertContainsEquals(new ChoiceView('en', 'en', 'англійська'), $choices);
54-
$this->assertContainsEquals(new ChoiceView('en_US', 'en_US', 'англійська (США)'), $choices);
5552
$this->assertContainsEquals(new ChoiceView('fr', 'fr', 'французька'), $choices);
5653
$this->assertContainsEquals(new ChoiceView('my', 'my', 'бірманська'), $choices);
5754
}

src/Symfony/Component/Translation/DataCollectorTranslator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ private function collectMessage($locale, $domain, $id, $translation, $parameters
157157
$id = (string) $id;
158158
$catalogue = $this->translator->getCatalogue($locale);
159159
$locale = $catalogue->getLocale();
160+
$fallbackLocale = null;
160161
if ($catalogue->defines($id, $domain)) {
161162
$state = self::MESSAGE_DEFINED;
162163
} elseif ($catalogue->has($id, $domain)) {
@@ -165,10 +166,9 @@ private function collectMessage($locale, $domain, $id, $translation, $parameters
165166
$fallbackCatalogue = $catalogue->getFallbackCatalogue();
166167
while ($fallbackCatalogue) {
167168
if ($fallbackCatalogue->defines($id, $domain)) {
168-
$locale = $fallbackCatalogue->getLocale();
169+
$fallbackLocale = $fallbackCatalogue->getLocale();
169170
break;
170171
}
171-
172172
$fallbackCatalogue = $fallbackCatalogue->getFallbackCatalogue();
173173
}
174174
} else {
@@ -177,6 +177,7 @@ private function collectMessage($locale, $domain, $id, $translation, $parameters
177177

178178
$this->messages[] = [
179179
'locale' => $locale,
180+
'fallbackLocale' => $fallbackLocale,
180181
'domain' => $domain,
181182
'id' => $id,
182183
'translation' => $translation,

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function testCollectMessages()
3434
'id' => 'foo',
3535
'translation' => 'foo (en)',
3636
'locale' => 'en',
37+
'fallbackLocale' => null,
3738
'domain' => 'messages',
3839
'state' => DataCollectorTranslator::MESSAGE_DEFINED,
3940
'parameters' => [],
@@ -42,7 +43,8 @@ public function testCollectMessages()
4243
$expectedMessages[] = [
4344
'id' => 'bar',
4445
'translation' => 'bar (fr)',
45-
'locale' => 'fr',
46+
'locale' => 'en',
47+
'fallbackLocale' => 'fr',
4648
'domain' => 'messages',
4749
'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK,
4850
'parameters' => [],
@@ -52,6 +54,7 @@ public function testCollectMessages()
5254
'id' => 'choice',
5355
'translation' => 'choice',
5456
'locale' => 'en',
57+
'fallbackLocale' => null,
5558
'domain' => 'messages',
5659
'state' => DataCollectorTranslator::MESSAGE_MISSING,
5760
'parameters' => ['%count%' => 0],
@@ -60,7 +63,8 @@ public function testCollectMessages()
6063
$expectedMessages[] = [
6164
'id' => 'bar_ru',
6265
'translation' => 'bar (ru)',
63-
'locale' => 'ru',
66+
'locale' => 'en',
67+
'fallbackLocale' => 'ru',
6468
'domain' => 'messages',
6569
'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK,
6670
'parameters' => [],
@@ -69,7 +73,8 @@ public function testCollectMessages()
6973
$expectedMessages[] = [
7074
'id' => 'bar_ru',
7175
'translation' => 'bar (ru)',
72-
'locale' => 'ru',
76+
'locale' => 'en',
77+
'fallbackLocale' => 'ru',
7378
'domain' => 'messages',
7479
'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK,
7580
'parameters' => ['foo' => 'bar'],

src/Symfony/Component/Validator/Constraints/UrlValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class UrlValidator extends ConstraintValidator
2626
(%s):// # protocol
2727
(([\.\pL\pN-]+:)?([\.\pL\pN-]+)@)? # basic auth
2828
(
29-
([\pL\pN\pS\-\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
29+
([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
3030
| # or
3131
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address
3232
| # or

src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public function getValidLanguages()
7373
{
7474
return [
7575
['en'],
76-
['en_US'],
7776
['my'],
7877
];
7978
}

src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public function getValidUrls()
106106
['http://www.example.museum'],
107107
['https://example.com/'],
108108
['https://example.com:80/'],
109+
['http://examp_le.com'],
110+
['http://www.sub_domain.examp_le.com'],
109111
['http://www.example.coop/'],
110112
['http://www.test-example.com/'],
111113
['http://www.symfony.com/'],
@@ -239,7 +241,6 @@ public function getInvalidUrls()
239241
['://example.com'],
240242
['http ://example.com'],
241243
['http:/example.com'],
242-
['http://examp_le.com'],
243244
['http://example.com::aa'],
244245
['http://example.com:aa'],
245246
['ftp://example.fr'],

0 commit comments

Comments
 (0)
0