8000 Merge branch '5.4' into 6.3 · symfony/symfony@969d39a · GitHub
[go: up one dir, main page]

Skip to content

Commit 969d39a

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: [Translation] Prevent creating empty keys when key ends with a period #51928 Missing translations for Belarusian (be)
2 parents e6a141f + 4825733 commit 969d39a

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

src/Symfony/Component/Translation/Tests/Util/ArrayConverterTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,34 @@ public static function messagesData()
6969
],
7070
],
7171
],
72+
[
73+
// input
74+
[
75+
'foo.' => 'foo.',
76+
'.bar' => '.bar',
77+
'abc.abc' => 'value',
78+
'bcd.bcd.' => 'value',
79+
'.cde.cde.' => 'value',
80+
'.def.def' => 'value',
81+
],
82+
// expected output
83+
[
84+
'foo.' => 'foo.',
85+
'.bar' => '.bar',
86+
'abc' => [
87+
'abc' => 'value',
88+
],
89+
'bcd' => [
90+
'bcd.' => 'value',
91+
],
92+
'.cde' => [
93+
'cde.' => 'value',
94+
],
95+
'.def' => [
96+
'def' => 'value',
97+
],
98+
],
99+
],
72100
];
73101
}
74102
}

src/Symfony/Component/Translation/Util/ArrayConverter.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function expandToTree(array $messages): array
3636
$tree = [];
3737

3838
foreach ($messages as $id => $value) {
39-
$referenceToElement = &self::getElementByPath($tree, explode('.', $id));
39+
$referenceToElement = &self::getElementByPath($tree, self::getKeyParts($id));
4040

4141
$referenceToElement = $value;
4242

@@ -63,6 +63,7 @@ private static function &getElementByPath(array &$tree, array $parts): mixed
6363
$elem = &$elem[implode('.', \array_slice($parts, $i))];
6464
break;
6565
}
66+
6667
$parentOfElem = &$elem;
6768
$elem = &$elem[$part];
6869
}
@@ -94,4 +95,45 @@ private static function cancelExpand(array &$tree, string $prefix, array $node):
9495
}
9596
}
9697
}
98+
99+
private static function getKeyParts(string $key)
100+
{
101+
$parts = explode('.', $key);
102+
$partsCount = \count($parts);
103+
104+
$result = [];
105+
$buffer = '';
106+
107+
foreach ($parts as $index => $part) {
108+
if (0 === $index && '' === $part) {
109+
$buffer = '.';
110+
111+
continue;
112+
}
113+
114+
if ($index === $partsCount - 1 && '' === $part) {
115+
$buffer .= '.';
116+
$result[] = $buffer;
117+
118+
continue;
119+
}
120+
121+
if (isset($parts[$index + 1]) && '' === $parts[$index + 1]) {
122+
$buffer .= $part;
123+
124+
continue;
125+
}
126+
127+
if ($buffer) {
128+
$result[] = $buffer.$part;
129+
$buffer = '';
130+
131+
continue;
132+
}
133+
134+
$result[] = $part;
135+
}
136+
137+
return $result;
138+
}
97139
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>Значэнне сеткавай маскі павінна быць ад {{min}} да {{max}}.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>Назва файла занадта доўгая. Ён павінен мець {{ filename_max_length }} сімвал або менш.|Назва файла занадта доўгая. Ён павінен мець {{ filename_max_length }} сімвалы або менш.|Назва файла занадта доўгая. Ён павінен мець {{ filename_max_length }} сімвалаў або менш.</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>Надзейнасць пароля занадта нізкая. Выкарыстоўвайце больш надзейны пароль.</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>Гэта значэнне змяшчае сімвалы, якія не дазволены цяперашнім узроўнем абмежаванняў.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>Выкарыстанне нябачных сімвалаў не дазваляецца.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>Змешванне лікаў з розных алфавітаў не дапускаецца.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>Выкарыстанне схаваных накладзеных сімвалаў не дазваляецца.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

0 commit comments

Comments
 (0)
0