Prepare for i18n-models load data from arrays $this->title and $this->body
182069
protected function prepareI18nData($langCode)
    {
        $data = [];
        //var_dump($this->title);var_dump($this->body);
        if (is_array($this->title) && is_array($this->body)) {
            $data = [
                'title' => empty($this->title[$langCode]) ? '' : $this->title[$langCode],
                'body'  => empty($this->body[$langCode])  ? '' : $this->body[$langCode],
                'news_id' => $this->id,
                'lang_code' => $langCode,
            ];
        }//var_dump($data);
        return $data;
    }
181304
private function load()
    {
        // reset phrases
        $this->phrases = array();
        $this->loaded = true;

        // set file path
        $langDataPath = FS2LANG . '/' . $this->local . '/' . $this->type . '.txt';

        // include language data file
        if (file_exists($langDataPath)) {
            // load file
            $langData = file_get_contents($langDataPath);
            $langData = str_replace(array("\r\n", "\r"), "\n", $langData); // unify linebreaks
            $this->import($langData);

            // get lines
            $langData = preg_replace("/#.*?\n/is", '', $langData);
            $langData = explode("\n", $langData);

            // Run through lines
            foreach ($langData as $line) {
                preg_match("#([a-z0-9_-]+?)\s*?:\s*(.*)#is", $line, $match);
                if (count($match) >= 2) {
                    $this->add($match[1], $match[2]);
                }
                unset($match);
            }
        } else {
            Throw new \Exception('Language File not found: ' . $langDataPath);
        }
    }
305728
def _add_locale(locale, strings)
      `t = document.createElement('template');
      document.body.appendChild(t);
      t.classList.add('i18n');
      t.setAttribute('data-lang', #{locale})`

      strings.each do |k, v|
        `e=document.createElement('p');
        t.content.appendChild(e);
        e.id=#{k.gsub('.', '-')};
        e.textContent=#{v}`
      end
    end
346589
protected function prepareData()
    {
        if ($this->prepared) {
            return;
        }

        $this->presences         = new Collection;
        $this->modulePresences   = new Collection;
        $this->permissions       = [];
        $this->modulePermissions = [];

        $this->loadAclModules()
             ->collapsePermissions();

        $this->prepared = true;
    }
413190
protected function loadFormData()
    {
        parent::loadFormData();

        $surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID);

        if (isset($this->formData['survey']) &&
                $this->formData['survey'] &&
                (! $this->_survey instanceof \Gems_Tracker_Survey)) {

            $this->_survey = $this->loader->getTracker()->getSurvey($this->formData['survey']);
        }

        if ($this->_survey instanceof \Gems_Tracker_Survey) {
            // Add (optional) survey specific translators
            $extraTrans  = $this->importLoader->getAnswerImporters($this->_survey);
            if ($extraTrans) {
                $this->importTranslators = $extraTrans + $this->importTranslators;

                $this->_translatorDescriptions = false;

                $this->importModel->set('trans', 'multiOptions', $this->getTranslatorDescriptions());
            }
        }

        if ($this->_survey instanceof \Gems_Tracker_Survey) {
            $this->targetModel = $this->_survey->getAnswerModel($this->locale->toString());
            $this->importer->setTargetModel($this->targetModel);

            $source = $this->menu->getParameterSource();
            $source->offsetSet('gsu_has_pdf', $this->_survey->hasPdf() ? 1 : 0);
            $source->offsetSet('gsu_active', $this->_survey->isActive() ? 1 : 0);
        }
        // \MUtil_Echo::track($this->formData);
    }
632198
protected function loadFormData()
    {
        $model = $this->getModel();

        if ($this->request->isPost()) {
            $this->formData = $model->loadPostData($this->request->getPost() + $this->formData, true);

        } else {
            // Assume that if formData is set it is the correct formData
            if (! $this->formData)  {
                $this->formData = $model->loadNew();
            }
        }

        if (isset($this->formData['gtr_id_track']) && $this->formData['gtr_id_track']) {
            $this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->formData['gtr_id_track']);
        }
        if (! (isset($this->formData['importId']) && $this->formData['importId'])) {
            $this->formData['importId'] = mt_rand(10000,99999) . time();
        }
        $this->_session = new \Zend_Session_Namespace(__CLASS__ . '-' . $this->formData['importId']);

        if (! (isset($this->_session->localfile) && $this->_session->localfile)) {
            $importLoader = $this->loader->getImportLoader();

            $this->_session->localfile = \MUtil_File::createTemporaryIn(
                    $importLoader->getTempDirectory(),
                    $this->request->getControllerName() . '_'
                    );
        }

        // \MUtil_Echo::track($this->formData);
    }
1215912
private function load()
    {
        // Get English version
        $english = $this->getTranslations(__DIR__, 'en');
        $languages = $this->getLanguages();

        $this->compareTranslations($english, $languages);
    }
1216120
public function filterI18NColumn()
    {
        $overrideData = array_only($this->attributes, $this->i18n_fillable);
        if (!empty($overrideData)) {
            $this->i18n_data[$this->i18n_default_locale] = $overrideData;
            foreach ($this->i18n_fillable as $key) {
                unset($this->$key);
            }
        }

        if (isset($this->attributes[$this->i18n_attribute_name])) {
            $this->i18n_data = $this->attributes[$this->i18n_attribute_name];
            unset($this->attributes[$this->i18n_attribute_name]);
        }
    }
309646
function(data) {
		try {
		    this.options.language = new TL.Language(this.options);

		    this._initData(data);
		} catch(e) {
		    this.showMessage(this._translateError(e));
		}
	}
1097832
protected function initTranslations()
    {
        /** @var \yii\i18n\I18N $i18n */
        $i18n = Instance::ensure($this->i18n, \yii\i18n\I18N::class);
        $i18n->translations['recaptcha*'] = [
            'class' => PhpMessageSource::class,
            'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'messages',
            'sourceLanguage' => 'en',
            'fileMap' => [
                'recaptcha' => 'recaptcha.php',
            ],
        ];
    }
986091
protected function prepareMessageBody()
    {
        $attachments = $this->getSectionAttachments();
        if ($attachments) {
            $this->appendHeaderFields($this->contentInfoArray('multipart/mixed'));
            if (!empty($this->_text_plain) && !empty($this->_text_html)) {
                $this->_body = $this->boundaryDelimiterLine('multipart/mixed')
                            . $this->contentInfoString('multipart/alternative')
                            . $this->getSectionMultipartAlternative()
                            . $attachments
                ;
            } elseif (!empty($this->_text_plain)) {
                $this->_body = $this->boundaryDelimiterLine('multipart/mixed')
                            . $this->contentInfoString('text/plain')
                            . $this->getSectionTextPlain()
                            . $attachments
                ;
            } elseif (!empty($this->_text_html)) {
                $this->_body = $this->boundaryDelimiterLine('multipart/mixed')
                            . $this->contentInfoString('text/html')
                            . $this->getSectionTextHtml()
                            . $attachments
                ;
            } else {
                $this->_body = $attachments;
            }
            $this->_body .= $this->finalBoundaryDelimiterLine('multipart/mixed');
        } elseif (!empty($this->_text_plain) && !empty($this->_text_html)) {
            $this->appendHeaderFields($this->contentInfoArray('multipart/alternative'));
            $this->_body = $this->getSectionMultipartAlternative();
        } elseif (!empty($this->_text_plain)) {
            $this->appendHeaderFields($this->contentInfoArray('text/plain'));
            $this->_body = $this->getSectionTextPlain();
        } elseif (!empty($this->_text_html)) {
            $this->appendHeaderFields($this->contentInfoArray('text/html'));
            $this->_body = $this->getSectionTextHtml();
        } else {
            throw new EmailGatewayException(__('No attachments or body text was set. Can not send empty email.'));
        }
    }
1083730
public function definition_after_data() {
        global $CFG, $DB, $OUTPUT;

        $mform = $this->_form;

        // If language does not exist, use site default lang.
        if ($langsel = $mform->getElementValue('lang')) {
            $lang = reset($langsel);
            // Check lang exists.
            if (!get_string_manager()->translation_exists($lang, false)) {
                $langel =& $mform->getElement('lang');
                $langel->setValue(core_user::get_property_default('lang'));
            }
        }

    }
856322
function prepareFormData() {

            var data = {},
                matches,
                index;

            for (var i in formData) {
                if (!formData.hasOwnProperty(i)) continue;

                index = 0;
                matches = i.split(/\[(.+?)]/g);

                var tmpObject = {},
                    tmpArray = [];

                for (var k = matches.length - 1; k >= 0; k--) {
                    if (matches[k] === "") {
                        matches.splice(k, 1);
                        continue;
                    }

                    if (tmpArray.length < 1) {
                        tmpObject[matches[k]] = Number(formData[i]) || formData[i];
                    } else {
                        tmpObject = {};
                        tmpObject[matches[k]] = tmpArray[tmpArray.length - 1];
                    }
                    tmpArray.push(tmpObject)

                }

                data = $.extend(true, data, tmpObject);

            }

            formData = data;

        }
443992
function loadNamespaces(i18n, ns, cb) {
    i18n.loadNamespaces(ns, () => {
      // delay ready if not yet initialized i18n instance
      if (i18n.isInitialized) {
        cb();
      } else {
        const initialized = () => {
          // due to emitter removing issue in i18next we need to delay remove
          setTimeout(() => {
            i18n.off('initialized', initialized);
          }, 0);
          cb();
        };

        i18n.on('initialized', initialized);
      }
    });
  }
1324626
private function loadI18nValues(&$firstResult, $params) {
        if (!$this->entity instanceof AbstractI18nEntity) {

            return;
        }
        $filter = array($this->entity->getI18nIdentifier() => $firstResult[0]['id']);
        $localesKey = 'locales';

        if (is_array($params) && array_key_exists('locale', $params)) {
            $filter['locale'] = $params['locale'];
            $localesKey = $params['locale'];
        }

        $this->getQueryBuilder()->where($filter);
        $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ALL_ITEMS_QUERY, QueryBuilder::CHILD_ONLY);

        $i18nResult = $this->query($query);
        //file_put_contents('/var/www/shoppingcart/logs/test.log', '$i18nResult: '.print_r($i18nResult,true)."\r\n", FILE_APPEND);

        if ($localesKey == 'locales') {
            $firstResult[0]['locales'] = $this->getLocaleKeys($i18nResult, $this->getI18nValuesForPadding());
        } else {
            $firstResult[0]['locales'][$localesKey] = $i18nResult;
        }
    }
1274309
public static function load()
    {
        if (is_null(self::$loader)) {
            // Create loader object
            self::$loader = new \PhpMyAdmin\MoTranslator\Loader();

            // Set locale
            self::$loader->setlocale(
                self::$loader->detectlocale()
            );

            // Set default text domain
            self::$loader->textdomain('sqlparser');

            // Set path where to look for a domain
            self::$loader->bindtextdomain('sqlparser', __DIR__ . '/../locale/');
        }

        if (is_null(self::$translator)) {
            // Get translator
            self::$translator = self::$loader->getTranslator();
        }
    }
1357580
protected function rebuildTitles()
    {
        // Update the Title field in the dataobjects. This saves the time to build the title dynamically each time.
        foreach (TimeZoneData::get() as $tz) {
            $newTitle = $tz->prepareTitle();
            if ($newTitle != $tz->Title) {
                $tz->Title = $newTitle;
                $tz->write();
            }
        }
    }