Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
translate parameters, should fix #64
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlindhe committed Oct 19, 2018
1 parent 1353505 commit c1f8692
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ private function adjustArray(array $arr)
{
$res = [];
foreach ($arr as $key => $val) {
$key = $this->adjustString($key);

if (is_string($val)) {
$res[$key] = $this->adjustString($val);
Expand Down
23 changes: 23 additions & 0 deletions tests/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,29 @@ function testBasic()
$this->destroyLocaleFilesFrom($arr, $root);
}

function testBasicWithTranslationString()
{
$arr = [
'en' => [
'main' => [
'hello :name' => 'Hello :name',
]
],
];

$root = $this->generateLocaleFilesFrom($arr);
$this->assertEquals(
'export default {' . PHP_EOL
. ' "en": {' . PHP_EOL
. ' "main": {' . PHP_EOL
. ' "hello {name}": "Hello {name}"' . PHP_EOL
. ' }' . PHP_EOL
. ' }' . PHP_EOL
. '}' . PHP_EOL,
(new Generator([]))->generateFromPath($root));
$this->destroyLocaleFilesFrom($arr, $root);
}

function testBasicWithVendor()
{
$arr = [
Expand Down

0 comments on commit c1f8692

Please sign in to comment.