yii2-translateable
yii2-translateable copied to clipboard
After upgrading Yii to version 2.0.14 creating new translations not working
Before Yii version 2.0.14, the following code works well:
class PostController extends Controller
{
public function actionCreate()
{
$model = new Post();
foreach (Yii::$app->request->post('PostTranslation', []) as $language => $data) {
foreach ($data as $attribute => $translation) {
$model->translate($language)->$attribute = $translation;
}
}
//...
}
After upgrading Yii to version 2.0.14, the above code does not working. The related records in the post_translation
table are not created. If I update the newly created post
record, the translations are created in the post_translation
table.
Next algorithm works too
$template = new EmailTemplate();
$template->key = 'test';
$translation = $template->getTranslation('en');
$translation->subject = 'subject test';
$translation->body = 'body test';
$translation->hint = 'hint test';
$template->save();
$template->link('translations', $translation);
cc @kadarpeter
@creocoder I created pull request with fix of this issue. Can you check it, please?
Here is available supported new translatable behavior
extension. Try it :)
https://github.com/yiimaker/yii2-translatable
cc @kadarpeter @alex2549
@greeflas Thank YOU A LOT! Cause I faced that problem today as well, so your https://github.com/yiimaker/yii2-translatable behavior save me. Only one thing I ask you to add in your repo is instruction with migration example, that would help new users how to use it as well as it's done by @creocoder.
@SanChes-tanker Yes, I can. Please create an issue for this.