mirror of
https://github.com/symfony/ux-translator.git
synced 2026-03-24 00:12:19 +01:00
[Translator] Improve performance of dumper under certain condition
This commit is contained in:
committed by
Hugo Alliaume
parent
0f67df2893
commit
89233caf4c
@@ -99,29 +99,31 @@ class TranslationsDumper
|
||||
);
|
||||
}
|
||||
|
||||
$additions = [];
|
||||
$typescriptAdditions = [];
|
||||
foreach ($this->getTranslations($catalogues, $excludedDomains, $includedDomains, $includeKeysRegex, $excludeKeysRegex) as $translationId => $translationsByDomainAndLocale) {
|
||||
$translationId = str_replace('"', '\\"', $translationId);
|
||||
$this->filesystem->appendToFile($fileIndexJs, \sprintf(
|
||||
|
||||
$additions[] = \sprintf(
|
||||
' "%s": %s,%s',
|
||||
$translationId,
|
||||
json_encode(['translations' => $translationsByDomainAndLocale], \JSON_THROW_ON_ERROR),
|
||||
"\n"
|
||||
));
|
||||
);
|
||||
|
||||
if ($dumpTypeScript) {
|
||||
$this->filesystem->appendToFile($fileIndexDts, \sprintf(
|
||||
$typescriptAdditions[] = \sprintf(
|
||||
' "%s": %s;%s',
|
||||
$translationId,
|
||||
$this->getTranslationsTypeScriptTypeDefinition($translationsByDomainAndLocale),
|
||||
"\n"
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->filesystem->appendToFile($fileIndexJs, '};'."\n");
|
||||
|
||||
$this->filesystem->appendToFile($fileIndexJs, implode('', $additions).'};'."\n");
|
||||
if ($dumpTypeScript) {
|
||||
$this->filesystem->appendToFile($fileIndexDts, '};'."\n");
|
||||
$this->filesystem->appendToFile($fileIndexDts, implode('', $typescriptAdditions).'};'."\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user