Skip to content

Commit 59678dc

Browse files
Merge pull request #401 from N1ebieski:Fix-Translation-not-found-when-contains-non-standard-character-#43
Fix Translation not found when contains non-standard character
2 parents a64f6c6 + 701bcff commit 59678dc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

php-templates/translations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function linesFromJsonFile($file)
129129

130130
$lines = explode(PHP_EOL, $contents);
131131
$encoded = array_map(
132-
fn($k) => [json_encode($k), $k],
132+
fn($k) => [json_encode($k, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), $k],
133133
array_keys($json),
134134
);
135135
$result = [];
@@ -364,4 +364,4 @@ protected function fromPhpFile($file, $path, $namespace)
364364
'values' => array_keys($translator->values),
365365
'params' => array_map(fn($p) => json_decode($p, true), array_keys($translator->paramResults)),
366366
'to_watch' => $translator->directoriesToWatch,
367-
]);
367+
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);

src/templates/translations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ $translator = new class
129129
130130
$lines = explode(PHP_EOL, $contents);
131131
$encoded = array_map(
132-
fn($k) => [json_encode($k), $k],
132+
fn($k) => [json_encode($k, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), $k],
133133
array_keys($json),
134134
);
135135
$result = [];
@@ -364,5 +364,5 @@ echo json_encode([
364364
'values' => array_keys($translator->values),
365365
'params' => array_map(fn($p) => json_decode($p, true), array_keys($translator->paramResults)),
366366
'to_watch' => $translator->directoriesToWatch,
367-
]);
367+
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
368368
`;

0 commit comments

Comments
 (0)