Skip to content

Commit 494665c

Browse files
Merge branch '2.7' into 2.8
* 2.7: Various fixes esp. on Windows Fix the validation of form resources to register the default theme Fix the retrieval of the value with property path when using a loader [appveyor] minor enhancements [Process] Disable failing tests on Windows [Translation] Fix the string casting in the XliffFileLoader Windows and Intl fixes Add appveyor.yml for C.I. on Windows [VarDumper] fixed HtmlDumper to target specific the head tag [travis] merge php: nightly and deps=high test-matrix lines consistently use str_replace to unify directory separators Support omitting the <target> node in an .xlf file. Fix the handling of values for multiple choice types moved PHP nightly to PHP 7.0 [Security] Add missing docblock in PreAuthenticatedToken Conflicts: .travis.yml
2 parents 8e1fb7b + db65354 commit 494665c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Loader/XliffFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ public function load($resource, $locale, $domain = 'messages')
4848
foreach ($xml->xpath('//xliff:trans-unit') as $translation) {
4949
$attributes = $translation->attributes();
5050

51-
if (!(isset($attributes['resname']) || isset($translation->source)) || !isset($translation->target)) {
51+
if (!(isset($attributes['resname']) || isset($translation->source))) {
5252
continue;
5353
}
5454

5555
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
5656
// If the xlf file has another encoding specified, try to convert it because
5757
// simple_xml will always return utf-8 encoded values
58-
$target = $this->utf8ToCharset((string) $translation->target, $encoding);
58+
$target = $this->utf8ToCharset((string) (isset($translation->target) ? $translation->target : $source), $encoding);
5959

6060
$catalogue->set((string) $source, $target, $domain);
6161

Tests/Loader/XliffFileLoaderTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function testLoad()
2525
$this->assertEquals('en', $catalogue->getLocale());
2626
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
2727
$this->assertSame(array(), libxml_get_errors());
28+
$this->assertContainsOnly('string', $catalogue->all('domain1'));
2829
}
2930

3031
public function testLoadWithInternalErrorsEnabled()
@@ -55,8 +56,7 @@ public function testIncompleteResource()
5556
$loader = new XliffFileLoader();
5657
$catalogue = $loader->load(__DIR__.'/../fixtures/resources.xlf', 'en', 'domain1');
5758

58-
$this->assertEquals(array('foo' => 'bar', 'key' => '', 'test' => 'with'), $catalogue->all('domain1'));
59-
$this->assertFalse($catalogue->has('extra', 'domain1'));
59+
$this->assertEquals(array('foo' => 'bar', 'extra' => 'extra', 'key' => '', 'test' => 'with'), $catalogue->all('domain1'));
6060
}
6161

6262
public function testEncoding()
@@ -145,7 +145,8 @@ public function testLoadNotes()
145145

146146
$this->assertEquals(array('notes' => array(array('priority' => 1, 'content' => 'foo'))), $catalogue->getMetadata('foo', 'domain1'));
147147
// message without target
148-
$this->assertNull($catalogue->getMetadata('extra', 'domain1'));
148+
$this->assertEquals(array('notes' => array(array('content' => 'bar', 'from' => 'foo'))), $catalogue->getMetadata('extra', 'domain1'));
149+
// message with empty target
149150
$this->assertEquals(array('notes' => array(array('content' => 'baz'), array('priority' => 2, 'from' => 'bar', 'content' => 'qux'))), $catalogue->getMetadata('key', 'domain1'));
150151
}
151152
}

0 commit comments

Comments
 (0)