Skip to content

Commit

Permalink
Fix translated fields not switching to fallback language (closes #14)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuscris committed Mar 17, 2019
1 parent e95b953 commit 4c02b73
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions admin/src/Fields/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -31,6 +38,8 @@ public static function translate(Field $field)
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;
Expand Down

0 comments on commit 4c02b73

Please sign in to comment.