Skip to content

Commit 6031d76

Browse files
committed
bug symfony#13053 [FrameworkBundle] Fixed Translation loader and update translation command. (saro0h)
This PR was merged into the 2.3 branch. Discussion ---------- [FrameworkBundle] Fixed Translation loader and update translation command. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ This patch verifies that the directory to load translations exists in ``FrameworkBundle/Translation/TranslationLoader.php`` and stop the command if there are no translation found. **Before, when loading messages** : ![capture d ecran 2014-12-20 a 14 55 52](https://cloud.githubusercontent.com/assets/667519/5515053/09f4655c-8859-11e4-8231-fc6587ace5eb.png) **After, when loading messages** : ![capture d ecran 2014-12-20 a 15 01 36](https://cloud.githubusercontent.com/assets/667519/5515056/216a9fbc-8859-11e4-87a2-9e452df708a5.png) --------------------------- **Before, when writing messages** : ![capture d ecran 2014-12-20 a 14 57 50](https://cloud.githubusercontent.com/assets/667519/5515058/508c3184-8859-11e4-9456-f8e47190d3cd.png) **After, when writing messages** : ![capture d ecran 2014-12-20 a 15 03 47](https://cloud.githubusercontent.com/assets/667519/5515062/711f61d2-8859-11e4-8d15-d27700ac0a0f.png) --------------------------- **Before when loading message and there was no messages found**: ![capture d ecran 2014-12-20 a 15 05 36](https://cloud.githubusercontent.com/assets/667519/5515065/afe422a4-8859-11e4-9d2d-8f8399555462.png) **After when loading message and there was no messages found**: ![capture d ecran 2014-12-20 a 15 06 48](https://cloud.githubusercontent.com/assets/667519/5515070/da0247dc-8859-11e4-8cd7-127435441ffd.png) Commits ------- 2ca438d [FrameworkBundle] Fixed Translation loader and update translation command.
2 parents 1532b4e + 2ca438d commit 6031d76

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
116116
? new DiffOperation($currentCatalogue, $extractedCatalogue)
117117
: new MergeOperation($currentCatalogue, $extractedCatalogue);
118118

119+
// Exit if no messages found.
120+
if (!count($operation->getDomains())) {
121+
$output->writeln("\n<comment>No translation found.</comment>");
122+
123+
return;
124+
}
125+
119126
// show compiled list of messages
120127
if ($input->getOption('dump-messages') === true) {
121128
foreach ($operation->getDomains() as $domain) {

src/Symfony/Bundle/FrameworkBundle/Translation/TranslationLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function addLoader($format, LoaderInterface $loader)
4747
*/
4848
public function loadMessages($directory, MessageCatalogue $catalogue)
4949
{
50+
if (!is_dir($directory)) {
51+
return;
52+
}
53+
5054
foreach ($this->loaders as $format => $loader) {
5155
// load any existing translation files
5256
$finder = new Finder();

src/Symfony/Component/Translation/Writer/TranslationWriter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public function writeTranslations(MessageCatalogue $catalogue, $format, $options
6767
// get the right dumper
6868
$dumper = $this->dumpers[$format];
6969

70+
if (isset($options['path']) && !is_dir($options['path'])) {
71+
mkdir($options['path'], 0777, true);
72+
}
73+
7074
// save
7175
$dumper->dump($catalogue, $options);
7276
}

0 commit comments

Comments
 (0)