Skip to content
Open
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
6 changes: 3 additions & 3 deletions Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ public static function create($id, $domain = 'messages')
}

/**
* @param $id
* @param string $id
* @param string $domain
*/
public function __construct($id, $domain = 'messages')
{
$this->id = $id;
$this->id = (string)$id;
$this->domain = $domain;
}

Expand Down Expand Up @@ -257,4 +257,4 @@ public function __toString()
{
return $this->id;
}
}
}
4 changes: 2 additions & 2 deletions Translation/Extractor/File/TwigFileExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
if ($node instanceof TransNode) {
$id = $node->getNode('body')->getAttribute('data');
$domain = 'messages';
if (null !== $domainNode = $node->getNode('domain')) {
if ($node->hasNode('domain') && null !== $domainNode = $node->getNode('domain')) {
$domain = $domainNode->getAttribute('value');
}

Expand Down Expand Up @@ -153,4 +153,4 @@ public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)

public function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue) { }
public function visitPhpFile(\SplFileInfo $file, MessageCatalogue $catalogue, array $ast) { }
}
}
7 changes: 6 additions & 1 deletion Translation/Loader/Symfony/XliffLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public function load($resource, $locale, $domain = 'messages')

$catalogue = new MessageCatalogue($locale);
foreach ($xml->xpath('//xliff:trans-unit') as $translation) {
$attributes = $translation->attributes();
if (!(isset($attributes['resname']) || isset($translation->source)) || !isset($translation->target) || !$translation->target->__toString() || (isset($translation->target['state']) && $translation->target['state'] == 'needs-translation')) {
continue;
}

$id = ($resName = (string) $translation->attributes()->resname)
? $resName : (string) $translation->source;

Expand All @@ -61,4 +66,4 @@ public function load($resource, $locale, $domain = 'messages')

return $catalogue;
}
}
}
9 changes: 9 additions & 0 deletions Translation/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ private function setConfig(Config $config)
$message->setLocaleString($message->getId());
}
}
} else {
// new translation set as empty
foreach ($this->scannedCatalogue->getDomains() as $domainCatalogue) {
foreach ($domainCatalogue->all() as $message) {
if ($message->isNew()){
$message->setLocaleString('');
}
}
}
}

// merge existing messages into scanned messages
Expand Down