aboutsummaryrefslogtreecommitdiff
path: root/cli/i18n/I18nFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'cli/i18n/I18nFile.php')
-rw-r--r--cli/i18n/I18nFile.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/cli/i18n/I18nFile.php b/cli/i18n/I18nFile.php
index 5a0c74aaa..8932bff57 100644
--- a/cli/i18n/I18nFile.php
+++ b/cli/i18n/I18nFile.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
require_once __DIR__ . '/I18nValue.php';
@@ -27,7 +28,7 @@ class I18nFile {
}
/**
- * @param array<string,array<array<string>>> $i18n
+ * @param array<string,array<string,array<string,I18nValue>>> $i18n
*/
public function dump(array $i18n): void {
foreach ($i18n as $language => $file) {
@@ -65,7 +66,7 @@ class I18nFile {
} catch (ParseError $ex) {
if (defined('STDERR')) {
fwrite(STDERR, "Error while processing: $filename\n");
- fwrite(STDERR, $ex);
+ fwrite(STDERR, $ex->getMessage());
}
die(1);
}
@@ -108,7 +109,7 @@ class I18nFile {
* The first key is dropped since it represents the filename and we have
* no use of it.
*
- * @param array<string> $translation
+ * @param array<string,I18nValue> $translation
* @return array<string,array<string,I18nValue>>
*/
private function unflatten(array $translation): array {
@@ -118,7 +119,7 @@ class I18nFile {
foreach ($translation as $compoundKey => $value) {
$keys = explode('.', $compoundKey);
array_shift($keys);
- eval("\$a['" . implode("']['", $keys) . "'] = '" . addcslashes($value, "'") . "';");
+ eval("\$a['" . implode("']['", $keys) . "'] = '" . addcslashes($value->__toString(), "'") . "';");
}
return $a;
@@ -131,7 +132,7 @@ class I18nFile {
* translation file. The array is first converted to a string then some
* formatting regexes are applied to match the original content.
*
- * @param array<string> $translation
+ * @param array<string,I18nValue> $translation
*/
private function format(array $translation): string {
$translation = var_export($this->unflatten($translation), true);