Translate form's fields.

@param  string $newLangFile

@return void
341351
private function templateVars($newLangFile)
    {
        $messages = [];
        foreach ($this->formFields as $field) {
            $index = $field['name'];
            $text = ucwords(strtolower(str_replace('_', ' ', $index)));
            $messages[] = "'$index' => '$text'";
        }

        File::put($newLangFile, str_replace('%%messages%%', implode(",\n", $messages), File::get($newLangFile)));
    }
38530
static function ModuleTranslationsFile(ModuleBase $module, $lang)
    {
        $folder = self::ModuleTranslationsFolder($module);
        $file = Path::Combine($folder, $lang);
        return Path::AddExtension($file, 'php');
    }
163184
private function populateTranslations()
    {
        //translations
        $aRelated = $this->owner->getRelatedRecords();
        if (isset($aRelated[$this->relation]) && $aRelated[$this->relation] != null) {
            if (is_array($aRelated[$this->relation])) {
                foreach ($aRelated[$this->relation] as $model) {
                    $this->_models[$model->getAttribute($this->languageField)] = $model;
                }
            } else {
                $model = $aRelated[$this->relation];
                $this->_models[$model->getAttribute($this->languageField)] = $model;
            }
        }
    }
1272965
function setLanguage () {
		if (!defined('LANGUAGES')){
			define('LANGUAGES', 'en');
		}	
		$this->i18nURL();
		if (!defined('LANG')){
			if (!$this->lang){
				$this->lang = 'en';
			}
			define('LANG', $this->lang);
		}
	}
616803
public function setTranslations($translations)
    {
        $this->currentState = self::UNFILTERED;
        $this->translations = $translations;
        $this->applyFilters();
    }
301899
public function loadLanguageFile(string $table)
    {
        if (!isset($GLOBALS['TL_LANG'][$table]) || null === $GLOBALS['TL_LANG'][$table]) {
            /** @var System $system */
            $system = $this->framework->getAdapter(System::class);

            $system->loadLanguageFile($table);
        }
    }
1210528
protected function addTranslation($string, array $translations, $file)
    {
        if ($this->prepared && !isset($this->written[$file][$string]) && !empty($this->context)) {

            $data = array($string);

            if (isset($translations[$string][0]) && $translations[$string][0] !== '') {
                $data = $translations[$string];
                array_unshift($data, $string);
            }

            gplcart_file_csv($file, $data);
            $this->written[$file][$string] = true;
        }
    }
1364594
private function disableUntranslatableForms(FormBuilderInterface $builder): void
    {
        foreach ($builder as $form) {
            /** @var \Symfony\Component\Form\FormBuilderInterface $form */
            $innerType = $form->getType()->getInnerType();
            $disabled = !$innerType instanceof ParametersType;

            $parameterDefinition = $form->getOption('ngbm_parameter_definition');
            if ($parameterDefinition instanceof ParameterDefinition) {
                $disabled = $parameterDefinition->getOption('translatable') !== true;
            }

            $form->setDisabled($disabled);

            if ($parameterDefinition instanceof ParameterDefinition) {
                continue;
            }

            $this->disableUntranslatableForms($form);
        }
    }
1223498
protected function transformTranslation(LocaleAwareInterface $translation, $fields, &$values)
    {
        foreach ($fields as $field) {
            $values[$translation->getLocale()][$field] = $this->propertyAccessor->getValue($translation, $field);
        }
    }
254118
public function setDefaultLocale($locale) {

		$this->defaultLocale = $locale;

		if (NULL === $this->locale) {
			$this->setPhpDefaultLocale($locale);
		}

	}
1295080
public function createNewLanguage(string $newLocale)
    {
        if (count($this->getAvailableLanguages()) >= $this->allowedLanguages) {
            throw new DirectoryNotCreatedException("Max number of allowed languages alread reached.");
        }

        if (!$this->fileSystem->makeDirectory($this->getLanguagesPath() . DIRECTORY_SEPARATOR . $newLocale)) {
            throw new DirectoryNotCreatedException("New directory for locale $newLocale cannot be created.");
        }

        return true;
    }
801026
private function copyFallbackTranslations($newLocale)
    {
        \DB::transaction(function () use ($newLocale) {

            $existingTranslations = Translation::get();
            $fallbackLanguage = Language::whereIsFallback(1)->first();

            if ($fallbackLanguage) {
                $fallbackIsoCode = $fallbackLanguage->iso_code;

                $fallbackTranslations = Translation::whereLocale($fallbackIsoCode)->get();

                if ($fallbackTranslations) {
                    $copiedTranslationsWithNewLocale = $fallbackTranslations->map(function ($translation) use (
                        $newLocale
                    ) {
                        unset($translation->id);
                        $translation->locale = mb_strtolower($newLocale);

                        return $translation;
                    })->toArray();

                    $translationsToCreate = [];

                    foreach ($copiedTranslationsWithNewLocale as $translation) {

                        // Safety feature - dont create entry if it already exists
                        // This might happen if administrator creates new language, deletes it, and then creates again
                        $exists = $existingTranslations
                            ->where('group', $translation['group'])
                            ->where('key', $translation['key'])
                            ->where('locale', $translation['locale'])
                            ->first();

                        if (!$exists) {
                            $translationsToCreate[] = $translation;
                        }
                    }

                    foreach (array_chunk($translationsToCreate, 300) as $chunk) {
                        Translation::insert($chunk);
                    }
                }
            }
        });
    }
740117
protected function generateLanguageFolders(): void
    {
        foreach($this->languages as $language){
            if(!is_dir($this->language_folder . $language)){
                if(!mkdir($this->language_folder . $language)){
                    $this->error("Error creating folder for language: $language");
                }
                $this->info("Folder created for language: $language");
            }
        }
    }
917170
public function addMissingTranslations($locales)
    {
        foreach ($locales as $localeCode) {
            if (!$this->hasTranslation($localeCode)) {
                $this->addTranslations(new MessageTranslation($localeCode, $this->getMessage()));
            }
        }

        foreach ($this->translations as $translation) {
            $translation->setMessage($this);
        }
    }
249298
public function parseTranslationFile() {
        $base_path = $this->getMinkParameter('files_path');
        $base_path = $base_path."/";
        $file_path = $base_path.$this->multilingual_parameters['translations'];
        $yaml = file_get_contents($file_path);
        $yaml_parse_array_check = Yaml::parse($yaml);
        if(is_array($yaml_parse_array_check)) {
            $this->translations = $yaml_parse_array_check;
        }
    }
714816
public function setLocale($locale)
    {
        $this['config']->set('app.locale', $locale);

        $this['translator']->setLocale($locale);

        $this['events']->dispatch(new Events\LocaleUpdated($locale));
    }
641372
protected function correctMethodName(File $phpCsFile, int $stackPointer, string $newMethodName): void
    {
        $phpCsFile->fixer->beginChangeset();
        $phpCsFile->fixer->replaceToken($stackPointer, $newMethodName);
        $phpCsFile->fixer->endChangeset();
    }