You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I mean by the title is that I expected setTranslations(string $key, array $translations) to set all the translations for $key, however if one looks at the code, it actually only overwrites existing translations.
For example:
$entity->setTranslations('title', ['en'=>'Tiitle', 'de' => 'Title']); // all good$entity->setTranslations('title', ['en'=>'Title']); // wait for it..
var_export($entity->getTranslations());
// => array( 'en' => 'Title', 'de' => 'Titel' ) <-- didn't expect 'de' to still be there
Looking at the code of forgetTranslation, I think it only really works because it ends up unsetting $this->$key
($entity->title). At the moment, I ended up using the same mechanism as well and it seems to work fine:
$entity->setTranslations('title', ['en'=>'Tiitle', 'de' => 'Title']); // all good
unset($entity->title);
$entity->setTranslations('title', ['en'=>'Title']);
var_export($entity->getTranslations());
// => array( 'en' => 'Title' ) <-- all good
The text was updated successfully, but these errors were encountered:
What I mean by the title is that I expected
setTranslations(string $key, array $translations)
to set all the translations for$key
, however if one looks at the code, it actually only overwrites existing translations.For example:
Looking at the code of
forgetTranslation
, I think it only really works because it ends up unsetting$this->$key
(
$entity->title
). At the moment, I ended up using the same mechanism as well and it seems to work fine:The text was updated successfully, but these errors were encountered: