Prepare multilang models array.
@return array of NewsI18n
196291
public static function prepareI18nModels($model)
    {//echo __METHOD__;var_dump($model->attributes);
        //$languages = LangHelper::activeLanguages();//var_dump($languages);
        //$config = Module::getModuleConfigByClassname(Module::className());//var_dump($config);
        //$langHelper = $config['params']['langHelper'];

        $moduleClass = static::moduleClass();//var_dump($module);exit;
        if (!$moduleClass) $moduleClass = Module::className(); //?? or better throw new \Exception("Can't found module for " . static::className());
        $module = UniModule::getModuleByClassname($moduleClass);

        $langHelper = $module->langHelper;
        //$languages = $langHelper::activeLanguages();//var_dump($languages);
        $editAllLanguages = empty($module->params['editAllLanguages']) ? false : $module->params['editAllLanguages'];
        $languages = $langHelper::activeLanguages($editAllLanguages);//var_dump($languages);exit;

        $mI18n = $model->i18n;//var_dump($mI18n);exit;

        //$conf = Module::getModuleConfigByClassname(Module::className());//var_dump($conf);
        //$contentHelperClass = $conf['params']['contentHelper'];
        //$module = Module::getModuleByClassname(Module::className());
        //$contentHelperClass = $module->contentHelper;
        //$contentHelper = new $contentHelperClass;

        $modelsI18n = [];
        foreach ($mI18n as $modelI18n) {//var_dump($modelI18n->attributes);
            //$modelI18n->body = $contentHelper::afterSelectBody($modelI18n->body); //!! move to self::correctI18nBodies()
            $modelsI18n[$modelI18n->lang_code] = $modelI18n;
        }
        $modelsI18n = static::correctI18nBodies($modelsI18n);//var_dump($modelsI18n);exit;

        foreach ($languages as $langCode => $lang) {
            if (empty($modelsI18n[$langCode])) {
                //$modelsI18n[$langCode] = (new NewsI18n())->loadDefaultValues();
                $newNewsI18n = $module::model('NewsI18n');//var_dump($newNewsI18n);exit;
                $modelsI18n[$langCode] = $newNewsI18n->loadDefaultValues();
                $modelsI18n[$langCode]->lang_code = $langCode;
            }
        }//var_dump($modelsI18n);exit;
        return $modelsI18n;
    }
974993
public function getAcceptLanguages(): array
    {
        $ls = [];

        if ($value = $this->getLine('Accept-Language')) {
            if (\strpos($value, ';')) {
                [$value,] = \explode(';', $value, 2);
            }

            $value = \str_replace(' ', '', $value);
            $ls    = \explode(',', $value);
        }

        return $ls;
    }
426334
public function Locales()
    {
        $data = [];
        foreach (Locale::getCached() as $localeObj) {
            /** @var Locale $localeObj */
            $data[] = $this->owner->LocaleInformation($localeObj->getLocale());
        }
        return ArrayList::create($data);
    }
140908
protected function getContentLanguageCodes()
    {
        return array_map(
            function($language) {
                return $language->languageCode;
            },
            array_filter(
                $this->repository->getContentLanguageService()->loadLanguages(),
                function ($language) {
                    return $language->enabled;
                }
            )
        );
    }
1056944
public function getManagedModels()
    {
        $models = $this->getVersionedModels();

        // Normalize models to have their model class in array key and all names as the value are uppercased
        foreach ($models as $k => $v) {
            $archivedModels[$v] = array('title' => ucfirst(singleton($v)->i18n_plural_name()));
            unset($archivedModels[$k]);
        }

        return $archivedModels;
    }
667491
public function actionIndex() {
        $languageForm = Yii::createObject([
                    'class' => Language::className(),
                    'scenario' => 'create'
        ]);
        $filterModel = Yii::createObject([
                    'class' => Language::className(),
                    'scenario' => 'search'
        ]);
        Yii::$app->view->title = Yii::t('multilang', 'Languages');
        return $this->render('index', [
                    'filterModel' => $filterModel,
                    'dataProvider' => $filterModel->search(Yii::$app->request->get()),
                    'languageForm' => $languageForm
        ]);
    }
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;
    }
675203
protected function getListLanguage()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            $list = $this->language->getList();
            $this->limitArray($list);
            return $list;
        }

        $result = $this->language->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
978887
public function encodings()
    {
        $encodings = [];
        $added = [];

        foreach ($this->candidates as $candidate) {
            foreach ($candidate->encodings() as $encoding) {
                if (isset($added[$encoding])) {
                    continue;
                }
                $encodings[] = $encoding;
                $added[$encoding] = true;
            }
        }

        return $encodings;
    }
448634
public function getI18n()
    {
        $id = $this->id;
        if (!static::$caching || empty(static::$_i18n[$id])) {
            $result = $this->prepareI18nModels();
            if (static::$caching) {
                static::$_i18n[$id] = $result;
            } else {
                return $result;
            }

        }
        return static::$_i18n[$id];
    }
1098771
public function langs()
    {
        $langs = [];
        $files = $this->getMLFiles();

        foreach( $files as $file )
        {
            $langs[] = $this->removeExtension($file);
        }
    
        return $langs;
    }
674871
public function rules(): array
    {
        $languages = TransHelper::getAllLanguages();
        $category = $this->route('category');

        $rules = [
            'icons.*' => 'image|max:4096',
        ];

        foreach ($languages as $language) {

            $translationInstance = null;
            $iso = $language->iso_code;

            if ($category) {
                $translationInstance = $category->translations()->where('locale', $language->iso_code)->first();
            }

            // Name
            $rules["translations.{$iso}.name"] = 'required';

            // Slug
            $uniqueSlug = Rule::unique('netcore_category__category_translations', 'slug')->ignore(
                object_get($translationInstance, 'id')
            );

            $rules["translations.{$iso}.slug"][] = 'nullable';
            $rules["translations.{$iso}.slug"][] = $uniqueSlug;
        }

        return $rules;
    }
306887
protected function prepareTranslations($translations) {
        $return = [];

        foreach($translations as $translation)
            $return[$translation['locale']][!is_null($translation['group']) ? $translation['group']. '.' . $translation['key'] : ''. $translation['key']] = $translation['value'];

       return $return;
    }
640399
public function getUiLangsList() {
		$result = [];
		$UIlangs = $this->_modelConfigSettingsApp->getUiLangs();
		if (empty($UIlangs)) {
			return $result;
		}

		$language = new Language();
		foreach ($UIlangs as $country => $UIlang) {
			$langName = $language->convertLangCode($UIlang, 'native');
			if (empty($langName)) {
				continue;
			}

			$result[$country] = mb_ucfirst($langName);
		}

		return $result;
	}
1175408
public function getHasTranslate()
    {
        $relations = $this->getRelation();
        $select = array_keys($relations->link);
        $select[] = $this->languageAttribute;

        return $relations
            ->select($select)
            ->indexBy($this->languageAttribute)
            ->asArray();
    }
780904
public function translatedAttributes() {
        if(! $attributes = isset($this['translatedAttributes']) ? $this['translatedAttributes'] : null) {
            $class = $this->classTranslation();

            $attributes = (new $class)
                ->getFillable();

            $attributes = array_except(array_flip($attributes),  [
                'language_id' ,
                str_singular($this->getModel()->getTable()) . '_id'
            ]);

            $attributes = array_flip($attributes);
        }

        return $attributes;
    }
776676
public function allTranslations()
    {
        $model = '\\'.get_class($this);

        // the translations
        $translations = $this->translations();

        $all_translations = new Collection();
        // the original
        if ($this->translation_of) {
            $original = $model::find($this->translation_of);
            $all_translations = $all_translations->push($original);

            // get all translations from the original
            $translationsOfOriginal = $model::where('translation_of', $original->id)->get();
            foreach($translationsOfOriginal as $translation) {
                $all_translations->push($translation);
            }
        } else {
            // prepend the translation to be first in the list of translations
            $all_translations = $translations->prepend($this);
        }

        return $all_translations;
    }