Skip to content

Commit c1f8692

Browse files
committed
translate parameters, should fix martinlindhe#64
1 parent 1353505 commit c1f8692

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/Generator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ private function adjustArray(array $arr)
234234
{
235235
$res = [];
236236
foreach ($arr as $key => $val) {
237+
$key = $this->adjustString($key);
237238

238239
if (is_string($val)) {
239240
$res[$key] = $this->adjustString($val);

tests/GenerateTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,29 @@ function testBasic()
8686
$this->destroyLocaleFilesFrom($arr, $root);
8787
}
8888

89+
function testBasicWithTranslationString()
90+
{
91+
$arr = [
92+
'en' => [
93+
'main' => [
94+
'hello :name' => 'Hello :name',
95+
]
96+
],
97+
];
98+
99+
$root = $this->generateLocaleFilesFrom($arr);
100+
$this->assertEquals(
101+
'export default {' . PHP_EOL
102+
. ' "en": {' . PHP_EOL
103+
. ' "main": {' . PHP_EOL
104+
. ' "hello {name}": "Hello {name}"' . PHP_EOL
105+
. ' }' . PHP_EOL
106+
. ' }' . PHP_EOL
107+
. '}' . PHP_EOL,
108+
(new Generator([]))->generateFromPath($root));
109+
$this->destroyLocaleFilesFrom($arr, $root);
110+
}
111+
89112
function testBasicWithVendor()
90113
{
91114
$arr = [

0 commit comments

Comments
 (0)