Skip to content

Commit d81b4f9

Browse files
Merge pull request #311 from balda38/unssupported-lang-files
Fix parsing of unsupported language files
2 parents f2c2b1d + 0cf8037 commit d81b4f9

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

php-templates/translations.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,16 @@ protected function linesFromPhpFile($file)
189189

190190
protected function getDotted($key, $lang)
191191
{
192-
return \Illuminate\Support\Arr::dot(
193-
\Illuminate\Support\Arr::wrap(
194-
__($key, [], $lang),
195-
),
196-
);
192+
try {
193+
return \Illuminate\Support\Arr::dot(
194+
\Illuminate\Support\Arr::wrap(
195+
__($key, [], $lang),
196+
),
197+
);
198+
} catch (\Throwable $e) {
199+
// Most likely, in this case, the lang file doesn't return an array
200+
return [];
201+
}
197202
}
198203

199204
protected function getPathIndex($file)

src/templates/translations.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,16 @@ $translator = new class
189189
190190
protected function getDotted($key, $lang)
191191
{
192-
return \\Illuminate\\Support\\Arr::dot(
193-
\\Illuminate\\Support\\Arr::wrap(
194-
__($key, [], $lang),
195-
),
196-
);
192+
try {
193+
return \\Illuminate\\Support\\Arr::dot(
194+
\\Illuminate\\Support\\Arr::wrap(
195+
__($key, [], $lang),
196+
),
197+
);
198+
} catch (\\Throwable $e) {
199+
// Most likely, in this case, the lang file doesn't return an array
200+
return [];
201+
}
197202
}
198203
199204
protected function getPathIndex($file)

0 commit comments

Comments
 (0)