Skip to content

Commit

Permalink
[Goliath] Display translation keys duplicates in the translation key
Browse files Browse the repository at this point in the history
  • Loading branch information
szeroual committed Aug 9, 2023
1 parent 977bddf commit 27819e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Command/ImportTranslationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,14 @@ protected function importTranslationFiles($finder)

foreach ($finder as $file) {
$this->output->write(sprintf('Importing <comment>"%s"</comment> ... ', $file->getPathname()));
$number = $importer->import($file, $this->input->getOption('force'), $this->input->getOption('merge'));
$forceUpdate = $this->input->getOption('force');
list($domain, $locale, $extention) = explode('.', $file->getFilename());
if(strpos($domain, 'messages') !== false) {

This comment has been minimized.

Copy link
@bartmcleod

bartmcleod Aug 10, 2023

Collaborator

Any domain that includes "messages" somewhere in the string will be affected. I want to suggest creating an implementation that addresses the specific problem, maybe through some (default) configuration, that states which domains to merge in which order. For example:

'merge' => [
    'messages',
    'messages+intl-icu', // or whatever is fashionable at the time
]

This comment has been minimized.

Copy link
@bartmcleod

bartmcleod Aug 10, 2023

Collaborator

This probably should be an array of arrays, to be able to specify sets that you would like to merge

if ($domain != 'messages') {
$forceUpdate = true;
}
}
$number = $importer->import($file, $forceUpdate, $this->input->getOption('merge'));
$this->output->writeln(sprintf('%d translations', $number));

$skipped = $importer->getSkippedKeys();
Expand Down
3 changes: 3 additions & 0 deletions Translation/Importer/FileImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public function import(\Symfony\Component\Finder\SplFileInfo $file, $forceUpdate
if (!isset($this->loaders[$extention])) {
throw new \RuntimeException(sprintf('No load found for "%s" format.', $extention));
}
if(strpos($domain, 'messages') !== false) {
$domain = 'messages';
}

$messageCatalogue = $this->loaders[$extention]->load($file->getPathname(), $locale, $domain);

Expand Down

0 comments on commit 27819e7

Please sign in to comment.