Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use realpath on root_dir #50

Merged
merged 1 commit into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ services:
- "Smarty_Internal_Templatelexer"
- "Smarty_Internal_Templateparser"
- "@prestashop.smarty"

prestashop.translation.parser.crowdin_php_parser:
class: PrestaShop\TranslationToolsBundle\Translation\Parser\CrowdinPhpParser

prestashop.translation.manager.original_string_manager:
class: PrestaShop\TranslationToolsBundle\Translation\Manager\OriginalStringManager
arguments:
- "@prestashop.translation.parser.crowdin_php_parser"

prestashop.translation.manager.translation_manager:
class: PrestaShop\TranslationToolsBundle\Translation\Manager\TranslationManager
arguments:
Expand All @@ -30,7 +30,7 @@ services:
arguments:
- "@prestashop.translation.parser.crowdin_php_parser"
- "@prestashop.translation.manager.original_string_manager"

prestashop.translation.chainextractor:
class: PrestaShop\TranslationToolsBundle\Translation\Extractor\ChainExtractor

Expand Down
17 changes: 10 additions & 7 deletions Translation/Dumper/XliffFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function dump(MessageCatalogue $messages, $options = array())
throw new \InvalidArgumentException('The file dumper needs a path option.');
}

$fs = new Filesystem();
// save a file for each domain
foreach ($messages->getDomains() as $domain) {
$domainPath = DomainHelper::getExportPath($domain);
Expand All @@ -74,7 +75,6 @@ public function dump(MessageCatalogue $messages, $options = array())
throw new \RuntimeException(sprintf('Unable to create directory "%s".', $directory));
}

$fs = new Filesystem();
$fs->dumpFile($fullpath, $this->formatCatalogue($messages, $domain, $options));
}
}
Expand All @@ -94,12 +94,15 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti
$xliffBuilder->setVersion('1.2');

foreach ($messages->all($domain) as $source => $target) {
if (!empty($source)) {
$metadata = $messages->getMetadata($source, $domain);
$metadata['file'] = Configuration::getRelativePath($metadata['file'], (!empty($options['root_dir']) ? $options['root_dir'] : false) );
$xliffBuilder->addFile($metadata['file'], $defaultLocale, $messages->getLocale());
$xliffBuilder->addTransUnit($metadata['file'], $source, $target, $this->getNote($metadata));
}
if (!empty($source)) {
$metadata = $messages->getMetadata($source, $domain);
$metadata['file'] = Configuration::getRelativePath(
$metadata['file'],
!empty($options['root_dir']) ? realpath($options['root_dir']) : false
);
$xliffBuilder->addFile($metadata['file'], $defaultLocale, $messages->getLocale());
$xliffBuilder->addTransUnit($metadata['file'], $source, $target, $this->getNote($metadata));
}
}

return html_entity_decode($xliffBuilder->build()->saveXML());
Expand Down