File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ trait HasTranslation
27
27
*/
28
28
protected $ translationModel ;
29
29
30
+ /**
31
+ * @var string
32
+ */
33
+ protected $ activeLocale ;
34
+
30
35
/**
31
36
* Bootstrap the trait
32
37
*/
@@ -149,7 +154,7 @@ public function unsetTranslation($locale, $key = null)
149
154
public function setAttribute ($ key , $ value )
150
155
{
151
156
if ($ this ->isTranslatable ($ key )) {
152
- $ this ->setTranslation ($ key , $ this ->getDefaultLocale (), $ value );
157
+ $ this ->setTranslation ($ key , $ this ->getActiveLocale (), $ value );
153
158
}
154
159
155
160
return parent ::setAttribute ($ key , $ value );
@@ -200,6 +205,26 @@ public function getDefaultLocale()
200
205
return config ('app.locale ' );
201
206
}
202
207
208
+ /**
209
+ * @return string
210
+ */
211
+ public function getActiveLocale (): string
212
+ {
213
+ if (! isset ($ this ->activeLocale )) {
214
+ $ this ->activeLocale = $ this ->getDefaultLocale ();
215
+ }
216
+
217
+ return $ this ->activeLocale ;
218
+ }
219
+
220
+ /**
221
+ * @param string $activeLocale
222
+ */
223
+ public function setActiveLocale (string $ activeLocale )
224
+ {
225
+ $ this ->activeLocale = $ activeLocale ;
226
+ }
227
+
203
228
/**
204
229
* @return string
205
230
*/
You can’t perform that action at this time.
0 commit comments