Skip to content

Commit c0d2db4

Browse files
authored
Fixes #15: Fixed saving translations
1 parent 7ff9d04 commit c0d2db4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/TranslateableBehavior.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ class TranslateableBehavior extends Behavior
3434
* @var string[] the list of attributes to be translated
3535
*/
3636
public $translationAttributes;
37+
38+
/**
39+
* Temp buffer for entity relations.
40+
*
41+
* @var array
42+
*/
43+
protected $relationsBuffer = [];
44+
3745

3846
/**
3947
* @inheritdoc
@@ -83,6 +91,8 @@ public function getTranslation($language = null)
8391

8492
foreach ($translations as $translation) {
8593
if ($translation->getAttribute($this->translationLanguageAttribute) === $language) {
94+
$this->relationsBuffer[] = $translation;
95+
8696
return $translation;
8797
}
8898
}
@@ -93,6 +103,7 @@ public function getTranslation($language = null)
93103
$translation = new $class();
94104
$translation->setAttribute($this->translationLanguageAttribute, $language);
95105
$translations[] = $translation;
106+
$this->relationsBuffer = $translations;
96107
$this->owner->populateRelation($this->translationRelation, $translations);
97108

98109
return $translation;

0 commit comments

Comments
 (0)