You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #1809 [Translator] Create valid constant names for keys starting with numeric chars (wolfgangweintritt)
This PR was merged into the 2.x branch.
Discussion
----------
[Translator] Create valid constant names for keys starting with numeric chars
If the key of a translation started with a numeric character, the constant's name would also start with a numeric character, thus resulting in a JS syntax error. Prefixing the constant's name with an underscore makes it valid.
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Issues | -
| License | MIT
Commits
-------
440b5ab [Translator] Create valid constant names for keys starting with numeric chars
Copy file name to clipboardExpand all lines: src/Translator/tests/TranslationsDumperTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,7 @@ public function testDump(): void
67
67
'what.count.4' => 'one: There is one %what%|more: There are more than one %what%',
68
68
'animal.dog-cat' => 'Dog and cat',
69
69
'animal.dog_cat' => 'Dog and cat (should not conflict with the previous one)',
70
+
'0starts.with.numeric' => 'Key starts with numeric char',
70
71
],
71
72
'foobar' => [
72
73
'post.num_comments' => 'There is 1 comment|There are %count% comments',
@@ -95,6 +96,7 @@ public function testDump(): void
95
96
'what.count.4' => 'one: Il y a une %what%|more: Il y a more than one %what%',
96
97
'animal.dog-cat' => 'Chien et chat',
97
98
'animal.dog_cat' => 'Chien et chat (ne doit pas rentrer en conflit avec la traduction précédente)',
99
+
'0starts.with.numeric' => 'La touche commence par un caractère numérique',
98
100
],
99
101
'foobar' => [
100
102
'post.num_comments' => 'Il y a 1 comment|Il y a %count% comments',
@@ -125,6 +127,7 @@ public function testDump(): void
125
127
export const WHAT_COUNT4 = {"id":"what.count.4","translations":{"messages":{"en":"one: There is one %what%|more: There are more than one %what%","fr":"one: Il y a une %what%|more: Il y a more than one %what%"}}};
126
128
export const ANIMAL_DOG_CAT = {"id":"animal.dog-cat","translations":{"messages":{"en":"Dog and cat","fr":"Chien et chat"}}};
127
129
export const ANIMAL_DOG_CAT_1 = {"id":"animal.dog_cat","translations":{"messages":{"en":"Dog and cat (should not conflict with the previous one)","fr":"Chien et chat (ne doit pas rentrer en conflit avec la traduction pr\u00e9c\u00e9dente)"}}};
130
+
export const _0STARTS_WITH_NUMERIC = {"id":"0starts.with.numeric","translations":{"messages":{"en":"Key starts with numeric char","fr":"La touche commence par un caract\u00e8re num\u00e9rique"}}};
128
131
129
132
JAVASCRIPT);
130
133
@@ -150,6 +153,7 @@ public function testDump(): void
0 commit comments