Fix translated fields not switching to fallback language (closes #14)

This commit is contained in:
Giuseppe Criscione 2019-03-17 13:41:34 +01:00
parent e95b953891
commit 4c02b73f3a

View File

@ -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;