classes/item/ElementItem.php
private function setLangProperties()
    {
        if (empty($this->obElement) || !$this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) {
            return;
        }

        //Check translate model property
        if (empty($this->obElement->translatable) || !is_array($this->obElement->translatable)) {
            return;
        }

        //Get active lang list from Translate plugin
        $arLangList = self::getActiveLangList();
        if (empty($arLangList)) {
            return;
        }

        //Process translatable fields
        foreach ($this->obElement->translatable as $sField) {
            //Check field name
            if (empty($sField) || (!is_string($sField) && !is_array($sField))) {
                continue;
            }

            if (is_array($sField)) {
                $sField = array_shift($sField);
            }

            if (!isset($this->arModelData[$sField]) || array_key_exists($sField, (array) $this->obElement->attachOne) || array_key_exists($sField, (array) $this->obElement->attachMany)) {
                continue;
            }

            //Save field value with different lang code
            foreach ($arLangList as $sLangCode) {
                $sLangField = $sField.'|'.$sLangCode;
                $sValue = $this->obElement->lang($sLangCode)->$sField;
                $this->setAttribute($sLangField, $sValue);
            }
        }
    }
private function setLangProperties()
    {
        if (empty($this->obElement) || !$this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) {
            return;
        }

        //Check translate model property
        if (empty($this->obElement->translatable) || !is_array($this->obElement->translatable)) {
            return;
        }

        //Get active lang list from Translate plugin
        $arLangList = self::getActiveLangList();
        if (empty($arLangList)) {
            return;
        }

        //Process translatable fields
        foreach ($this->obElement->translatable as $sField) {
            //Check field name
            if (empty($sField) || (!is_string($sField) && !is_array($sField))) {
                continue;
            }

            if (is_array($sField)) {
                $sField = array_shift($sField);
            }

            if (!isset($this->arModelData[$sField]) || array_key_exists($sField, (array) $this->obElement->attachOne) || array_key_exists($sField, (array) $this->obElement->attachMany)) {
                continue;
            }

            //Save field value with different lang code
            foreach ($arLangList as $sLangCode) {
                $sLangField = $sField.'|'.$sLangCode;
                $sValue = $this->obElement->lang($sLangCode)->$sField;
                $this->setAttribute($sLangField, $sValue);
            }
        }
    }
private function setLangProperties ( ) { if ( empty ( $ this -> obElement ) || ! $ this -> obElement -> isClassExtendedWith ( 'RainLab.Translate.Behaviors.TranslatableModel' ) ) { return ; } //Check translate model property if ( empty ( $ this -> obElement -> translatable ) || ! is_array ( $ this -> obElement -> translatable ) ) { return ; } //Get active lang list from Translate plugin $ arLangList = self :: getActiveLangList ( ) ; if ( empty ( $ arLangList ) ) { return ; } //Process translatable fields foreach ( $ this -> obElement -> translatable as $ sField ) { //Check field name if ( empty ( $ sField ) || ( ! is_string ( $ sField ) && ! is_array ( $ sField ) ) ) { continue ; } if ( is_array ( $ sField ) ) { $ sField = array_shift ( $ sField ) ; } if ( ! isset ( $ this -> arModelData [ $ sField ] ) || array_key_exists ( $ sField , ( array ) $ this -> obElement -> attachOne ) || array_key_exists ( $ sField , ( array ) $ this -> obElement -> attachMany ) ) { continue ; } //Save field value with different lang code foreach ( $ arLangList as $ sLangCode ) { $ sLangField = $ sField . '|' . $ sLangCode ; $ sValue = $ this -> obElement -> lang ( $ sLangCode ) -> $ sField ; $ this -> setAttribute ( $ sLangField , $ sValue ) ; } } }
Process translatable fields and save values, how 'field_name|lang_code'
Process translatable fields and save values how field_name|lang_code