Skip to content

Commit

Permalink
bug fix for translation update
Browse files Browse the repository at this point in the history
  • Loading branch information
grinry committed Apr 29, 2016
1 parent daf15f0 commit 1cc9a39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions Eloquent/Traits/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ protected static function bootTranslatable()
//Check if string was json or translation key
foreach ((array) with(new self)->translatable as $item) {
if ($model->{$item}) {
$updated_locales = array_filter($model->{$item}, function($var) {
return strlen(strip_tags(trim($var))) != 0;
});
$updated_locales = $model->{$item};

$original = $model->getOriginal($item);
$original_locales = json_decode($original, true);
Expand Down Expand Up @@ -96,6 +94,17 @@ protected static function bootTranslatable()

}

// public function __get($key)
// {
// if (in_array($key, (array) $this->translatable)) {
// if (array_key_exists($key, $this->attributes) || $this->hasGetMutator($key)) {
// return new Translate($this->getAttributeValue($key), static::class);
// }
// }
// // TODO: Implement __get() method.
// return parent::__get($key);
// }

/**
* @param array $attributes
* @param null $connection
Expand Down
2 changes: 1 addition & 1 deletion Eloquent/Translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Translate {
*/
public function __construct($string = '', $domain = '')
{
$decode = json_decode($string, true);
$decode = is_string($string) ? json_decode($string, true) : $string;
$this->translations = $decode ? $decode : [
config('app.fallback_locale') => $string
];
Expand Down

0 comments on commit 1cc9a39

Please sign in to comment.