Write translations to the file.

@param array $translations
@return void
343966
protected function writeToFile(array $translations): void
    {
        $excel = app('excel');
        $filename = config('netcore.module-translate.translations_file');

        $excel
            ->create($filename, function (LaravelExcelWriter $writer) use ($translations) {
                $writer->setTitle('Translations');

                $writer->sheet('Translations', function (LaravelExcelWorksheet $sheet) use ($translations) {
                    $sheet->fromArray($translations, '', 'A1');

                    $sheet->row(1, function ($row) {
                        $row->setFontWeight('bold');
                    });
                });
            })
            ->store('xlsx', resource_path('seed_translations'));
    }
246163
public function removeTranslation(\Haven\CoreBundle\Entity\ExternalLinkTranslation $translations)
    {
        $this->translations->removeElement($translations);
    }
1260067
final protected function addTranslation(\Gettext\Translations $translations, $string, $context = '')
    {
        if (is_string($string) && ($string !== '')) {
            $translations->insert($context, $string);
        }
    }
129153
public function writeHeaders(array $headers)
    {
        $bar = $this->table_connectorHeader;
        $header = $this->table_headerPart;

        foreach ($headers as $name => $length) {
            $bar .= str_pad('', $length + 2, $this->table_barFiller).$this->table_connectorHeader;

            $header .= ' '.str_pad($name, $length, ' ', STR_PAD_RIGHT).' '.$this->table_headerPart;
        }

        $this->output->writeln($bar);
        $this->output->writeln($header);
        $this->output->writeln($bar);
    }
1050965
public function export($domains = [], $force = null)
    {
        foreach ($this->formExportList($domains, $force) as $file => $translations) {
            if (!file_exists($file)) {
                (new Filesystem())->touch($file);
            }

            $currentTranslations = $this->parser->parse(file_get_contents($file)) ?? [];

            $currentTranslations = $this->flatten($currentTranslations);

            $translations = array_replace_recursive($currentTranslations, $translations);

            $this->exporter->export($file, $translations);
        }

        $this->translationManager->save($this->refresh);
        $this->refresh = [];
    }
784927
protected function doExport($outputFile, $translations, $format)
    {
        $this->output->writeln(sprintf('<comment>Output file: %s</comment>', $outputFile));
        $this->output->write(sprintf('<comment>%d translations to export: </comment>', count($translations)));

        try {
            $exported = $this->getContainer()->get('lexik_translation.exporter_collector')->export(
                $format,
                $outputFile,
                $translations
            );

            $this->output->writeln($exported ? '<comment>success</comment>' : '<error>fail</error>');
        } catch (\Exception $e) {
            $this->output->writeln(sprintf('<error>"%s"</error>', $e->getMessage()));
        }
    }
1361384
private function syncKeysFromFiles($translationFiles)
    {
        $this->info('Reading translation keys from files...');

        // An array of all translation keys as found in project files.
        $allKeysInFiles = $this->manager->collectFromFiles();

        foreach ($translationFiles as $fileName => $languages) {
            foreach ($languages as $languageKey => $path) {
                $fileContent = $this->manager->getFileContent($path);

                if (isset($allKeysInFiles[$fileName])) {
                    $missingKeys = array_diff($allKeysInFiles[$fileName], array_keys(array_dot($fileContent)));

                    foreach ($missingKeys as $i => $missingKey) {
                        if (Arr::has($fileContent, $missingKey)) {
                            unset($missingKeys[$i]);
                        }
                    }

                    $this->fillMissingKeys($fileName, $missingKeys, $languageKey);
                }
            }
        }
    }
1076530
protected function writeLocale($locale, array $lines = [])
    {
        $translations = ConvertToTree::fromFlattened($lines);

        foreach ($translations as $section => $trans) {
            $this->filesystem->put(
                $locale.'/'.$section.'.php',
                "<?php\n\n return ".var_export($trans, true).";\n"
            );
        }
    }
636310
public function removeTranslation(\Haven\CmsBundle\Entity\TextContentTranslation $translations) {
        $this->translations->removeElement($translations);
    }
1047320
public function addTranslation(BlogContentTranslation $translations) {
        $translations->setParent($this);
        $this->translations[] = $translations;

        return $this;
    }
1117742
public function write($messages, $newline = true) {
		if ($newline) {
			$messages.= "<br/>";
		}
		
		$msg = "<script>window.parent.Composer.consoleOutput(".json_encode($messages).")</script>";
		
		ChunckedUtils::writeChunk($msg);
	}
796215
private function normalizePropertyTranslations(array $translations)
    {
        $maxLength = 0;

        foreach ($translations as $property => $translation) {
            $length = strlen($property);

            if ($length > $maxLength) {
                $maxLength = $length;
            }
        }
        foreach ($translations as $property => $translation) {
            $translations[$property] = str_repeat(' ', $maxLength - strlen($property)).$translation;
        }

        ksort($translations);

        return $translations;
    }
67676
public function addTranslationArray(array $translations, $language)
    {
        $language = (string) $language;
        if ($language === '') {
            throw new \InvalidArgumentException('$language cannot be empty');
        }

        if (!isset($this->translations[$language])) {
            $this->translations[$language] = [];
        }

        $this->translations[$language] = array_merge(
            $this->translations[$language],
            $translations
        );
    }
371229
protected function setTranslationFile($name, array $headers)
    {
        $this->info('Set plugin translation file...');

        $textdomain = trim($headers['text_domain'], '\/ _-');
        $from = $this->path($name.'/languages/plugin-textdomain-en_US.po');
        $to = $this->path($name.'/languages/'.$textdomain.'-en_US.po');

        $this->files->move($from, $to);
    }
141
private function getTranslationGroups($lang = 'en'): void
    {
        $dir = resource_path('lang/'. $lang . '/');
        $files = array_diff(scandir($dir), array('..', '.'));

        foreach($files as $index => $filename){
            $groupname = str_replace(".php", "", $filename);
            $this->updateTranslationGroups($groupname);
        }

    }
797027
public static function generate(Translations $translations, array $options = [])
    {
        $options += static::$options;

        return self::toArray($translations, $options['includeHeaders'], true);
    }
974033
private static function fromArray(array $messages, Translations $translations)
    {
        foreach ($messages as $original => $translation) {
            if ($original === '') {
                self::extractHeaders($translation, $translations);
                continue;
            }

            $translations->insert(null, $original)->setTranslation($translation);
        }
    }