From e014781af421884bb9a01cff72bec064ca299528 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Tue, 4 Aug 2020 21:09:01 +0200 Subject: [PATCH] i18n: Add english as always available, and merge other languages in case of missing keys Signed-off-by: Marco Dickert --- compiler.php | 4 ++++ docker/php.ini | 3 +++ src/main.php | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 docker/php.ini diff --git a/compiler.php b/compiler.php index 1ea03e8..25d1888 100755 --- a/compiler.php +++ b/compiler.php @@ -38,6 +38,10 @@ foreach ($options as $key => $value) $langs = array_merge($langs, explode(",", $value)); $langs = array_unique($langs); $vars['default_lang'] = ($langs[0] == "all") ? "en" : $langs[0]; +// ensure english is available, as it gets merged with the other languages +// in case of missing keys in other languages. +if (!in_array("all", $langs) || !in_array("en", $langs)) + array_push($langs, "en"); if (in_array("all", $langs)) $langs = array_map( diff --git a/docker/php.ini b/docker/php.ini new file mode 100644 index 0000000..e53e719 --- /dev/null +++ b/docker/php.ini @@ -0,0 +1,3 @@ +max_execution_time = 0 +upload_max_filesize = 0 +post_max_size = 0 diff --git a/src/main.php b/src/main.php index 89e195b..5d85390 100644 --- a/src/main.php +++ b/src/main.php @@ -184,9 +184,10 @@ f00bar; $this->i18n = $i18n; if( in_array( $this->config['language'], array_keys( $this->i18n ) ) ) - $this->l = $this->i18n[$this->config['language']]; + // Merge english with the language in case of missing keys + $this->l = (object)array_merge((array)$this->i18n['en'], (array)$this->i18n[$this->config['language']]); else - $this->l = reset($this->i18n); + $this->l = $this->i18n['en']; if ($this->config['timezone']) date_default_timezone_set($this->config['timezone']);