This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

maxDubovsky
maxDubovsky

Basicaly, we need to save title in a mentioned language. We use rainlab.translate plugin. For some reson this way it doesn't work:

        $newPage = Page::find(1);
        $newPage->translateContext('en');
        $newPage->title = $title_en;
        $newPage->content_html = $content_en;

        $newPage->translateContext('ru');
        $newPage->title = $title_ru;
        $newPage->content_html = $content_ru;

Any suggestions ?

Using the attribute setter it does the thing but buggy. If you are under en language it doesn't save it but the rest are saved.

        $newPage->setTranslateAttribute('title', $title_en, 'en');
        $newPage->setTranslateAttribute('title', $title_ru, 'ru');
        $newPage->setTranslateAttribute('title', $title_lv, 'lv');

Last updated

maxDubovsky
maxDubovsky

$newPost->syncTranslatableAttributes();

maxDubovsky
maxDubovsky

$deliveryOption->translateContext('lv'); $deliveryOption->title = $title_lv; $deliveryOption->save(null, post('_session_key')); $deliveryOption->setAttributeTranslated('title', $title_en, 'en'); $deliveryOption->setAttributeTranslated('title', $title_ru, 'ru'); $deliveryOption->syncTranslatableAttributes(); $deliveryOption->save(null, post('_session_key'));

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.