From 4c02b73f3a2ca3e1288f690d70ed2173c655f5bc Mon Sep 17 00:00:00 2001 From: Giuseppe Criscione Date: Sun, 17 Mar 2019 13:41:34 +0100 Subject: [PATCH] Fix translated fields not switching to fallback language (closes #14) --- admin/src/Fields/Translator.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/admin/src/Fields/Translator.php b/admin/src/Fields/Translator.php index 215b3f83..51931c97 100644 --- a/admin/src/Fields/Translator.php +++ b/admin/src/Fields/Translator.php @@ -20,6 +20,13 @@ class Translator */ protected static $ignore = array('name', 'type', 'import', 'fields'); + /** + * Keys of which array value has to be ignored + * + * @var array + */ + protected static $ignoreArrayKeys = array('value', 'options'); + /** * Translate a field */ @@ -31,6 +38,8 @@ class Translator if (is_array($value)) { if (isset($value[$language])) { $value = $value[$language]; + } elseif (!in_array($key, static::$ignoreArrayKeys, true)) { + $value = array_shift($value); } } elseif (!is_string($value)) { continue;