Skip to content

Commit f14f51e

Browse files
authored
Merge branch 'master' into patch-1
2 parents 2aafe81 + fbe350b commit f14f51e

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

Changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
## 1.0.0
6+
7+
### Added
8+
9+
- Support for php-translation/common: 1.0
10+
11+
## 0.5.0
12+
13+
### Added
14+
15+
- Support for php-translation/common: 0.3
16+
- Added the "name" attribute on the "unit" node for XLIFF 2.0.
17+
518
## 0.4.0
619

720
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"require": {
1212
"php": "^5.5 || ^7.0",
13-
"php-translation/common": "^0.2.1",
13+
"php-translation/common": "^1.0",
1414
"symfony/translation": "^2.7 || ^3.0 || ^4.0",
1515
"nyholm/nsa": "^1.1"
1616
},

src/Dumper/Port/SymfonyPort.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public function dumpXliff2($defaultLocale, MessageCatalogue $messages, $domain,
3838
foreach ($messages->all($domain) as $source => $target) {
3939
$translation = $dom->createElement('unit');
4040
$translation->setAttribute('id', strtr(substr(base64_encode(hash('sha256', $source, true)), 0, 7), '/+', '._'));
41+
$name = $source;
42+
if (strlen($source) > 80) {
43+
$name = substr(md5($source), -7);
44+
}
45+
$translation->setAttribute('name', $name);
4146
$metadata = $messages->getMetadata($source, $domain);
4247

4348
// Add notes section

src/FileStorage.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Translation\Reader\TranslationReaderInterface;
1717
use Symfony\Component\Translation\Writer\TranslationWriterInterface;
1818
use Translation\Common\Model\Message;
19+
use Translation\Common\Model\MessageInterface;
1920
use Translation\Common\Storage;
2021
use Translation\Common\TransferableStorage;
2122

@@ -98,7 +99,7 @@ public function get($locale, $domain, $key)
9899
/**
99100
* {@inheritdoc}
100101
*/
101-
public function create(Message $m)
102+
public function create(MessageInterface $m)
102103
{
103104
$catalogue = $this->getCatalogue($m->getLocale());
104105
if (!$catalogue->defines($m->getKey(), $m->getDomain())) {
@@ -110,7 +111,7 @@ public function create(Message $m)
110111
/**
111112
* {@inheritdoc}
112113
*/
113-
public function update(Message $m)
114+
public function update(MessageInterface $m)
114115
{
115116
$catalogue = $this->getCatalogue($m->getLocale());
116117
$catalogue->set($m->getKey(), $m->getTranslation(), $m->getDomain());

src/Loader/XliffLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ private function getXmlErrors($internalErrors)
151151
{
152152
$errors = [];
153153
foreach (libxml_get_errors() as $error) {
154-
$errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)',
154+
$errors[] = sprintf(
155+
'[%s %s] %s (in %s - line %d, column %d)',
155156
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
156157
$error->code,
157158
trim($error->message),

0 commit comments

Comments
 (0)