8000 [2.1] Extracting translations support. by xaav · Pull Request #1259 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.1] Extracting translations support. #1259

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

Closed
wants to merge 13 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Updated update trans command.
  • Loading branch information
xaav committed Jun 9, 2011
commit e62f5d292e857d61ce9a720118fce09ce3e8002d
53 changes: 16 additions & 37 deletions src/Symfony/Bundle/FrameworkBundle/Command/TransUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class UpdateTransCommand extends Command {
protected function configure()
{
$this
->setName('bcc:trans:update')
->setName('trans:update')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use translations: instead of trans:

->setDescription('Update the translation file')
->setDefinition(array(
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
Expand Down Expan E3C8 d Up @@ -94,34 +94,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->_crawlNode($tree);
}

// load any existing yml translation files
$finder = new Finder();
$files = $finder->files()->name('*.' . $input->getArgument('locale') . '.yml')->in($bundleTransPath);
foreach ($files as $file) {
$output->writeln(sprintf(' > parsing translation <comment>%s</comment>', $file->getPathname()));
$domain = substr($file->getFileName(), 0, strrpos($file->getFileName(), $input->getArgument('locale') . '.yml') - 1);
$yml_loader = new \Symfony\Component\Translation\Loader\YamlFileLoader();
$this->messages->addCatalogue($yml_loader->load($file->getPathname(), $input->getArgument('locale'), $domain));
}

// load any existing xliff translation files
$finder = new Finder();
$files = $finder->files()->name('*.' . $input->getArgument('locale') . '.xliff')->in($bundleTransPath);
foreach ($files as $file) {
$output->writeln(sprintf(' > parsing translation <comment>%s</comment>', $file->getPathname()));
$domain = substr($file->getFileName(), 0, strrpos($file->getFileName(), $input->getArgument('locale') . '.xliff') - 1);
$loader = new \Symfony\Component\Translation\Loader\XliffFileLoader();
$this->messages->addCatalogue($loader->load($file->getPathname(), $input->getArgument('locale'), $domain));
}

// load any existing php translation files
$finder = new Finder();
$files = $finder->files()->name('*.' . $input->getArgument('locale') . '.php')->in($bundleTransPath);
foreach ($files as $file) {
$output->writeln(sprintf(' > parsing translation <comment>%s</comment>', $file->getPathname()));
$domain = substr($file->getFileName(), 0, strrpos($file->getFileName(), $input->getArgument('locale') . '.php') - 1);
$loader = new \Symfony\Component\Translation\Loader\PhpFileLoader();
$this->messages->addCatalogue($loader->load($file->getPathname(), $input->getArgument('locale'), $domain));
foreach($this->container->findTaggedServiceIds('translation.loader') as $id => $attributes) {
// load any existing translation files
$finder = new Finder();
$files = $finder->files()->name('*.' . $input->getArgument('locale') . $attributes[0]['alias'])->in($bundleTransPath);
foreach ($files as $file) {
$output->writeln(sprintf(' > parsing translation <comment>%s</comment>', $file->getPathname()));
$domain = substr($file->getFileName(), 0, strrpos($file->getFileName(), $input->getArgument('locale') . $attributes[0]['alias']) - 1);
$loader = $this->container->get($id);
$this->messages->addCatalogue($loader->load($file->getPathname(), $input->getArgument('locale'), $domain));
}
}

// show compiled list of messages
Expand All @@ -136,14 +118,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
if($input->getOption('force') === true) {
$output->writeln("\nWriting files.\n");
$path = $foundBundle->getPath() . '/Resources/translations/';
if ($input->getOption('output-format') == 'yml') {
$formatter = new \BCC\ExtraToolsBundle\Translation\Formatter\YmlFormatter();
} elseif ($input->getOption('output-format') == 'php') {
$formatter = new \BCC\ExtraToolsBundle\Translation\Formatter\PhpFormatter();
} elseif ($input->getOption('output-format') == 'pot') {
$formatter = new \BCC\ExtraToolsBundle\Translation\Formatter\PotFormatter();
} else {
$formatter = new \BCC\ExtraToolsBundle\Translation\Formatter\XliffFormatter($input->getOption('source-lang'));
foreach($this->container->findTaggedServiceIds('translation.formatter') as $id => $attributes) {
if ($input->getOption('output-format') == $attributes[0]['alias']) {
$formatter = $this->container->get($id);
break;
}
}
foreach ($this->messages->getDomains() as $domain) {
$file = $domain . '.' . $input->getArgument('locale') . '.' . $input->getOption('output-format');
Expand Down
0