Skip to content
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

add source & target language headers #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions src/Generators/Xliff.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public static function toString(Translations $translations, array $options = [])
$xliff = $dom->appendChild($dom->createElement('xliff'));
$xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:2.0');
$xliff->setAttribute('version', '2.0');
$xliff->setAttribute('srcLang', $translations->getLanguage());
$xliff->setAttribute('trgLang', $translations->getLanguage());
$xliff->setAttribute('srcLang', $translations->getHeader('X-Source-Language')?: $translations->getLanguage());
$xliff->setAttribute('trgLang', $translations->getHeader('X-Target-Language')?: $translations->getLanguage());
$file = $xliff->appendChild($dom->createElement('file'));
$file->setAttribute('id', $translations->getDomain().'.'.$translations->getLanguage());

Expand Down
2 changes: 2 additions & 0 deletions src/Translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class Translations extends ArrayObject
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8',
'Content-Transfer-Encoding' => '8bit',
'X-Target-Language' => '',
'X-Source-Language' => '',
],
'headersSorting' => false,
'defaultDateHeaders' => [
Expand Down
26 changes: 13 additions & 13 deletions tests/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testPo()
$translations = static::get('po/input', 'Po');
$countTranslations = 3;
$countTranslated = 3;
$countHeaders = 9;
$countHeaders = 11;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -54,7 +54,7 @@ public function testPo2()
$translations = static::get('po2/input', 'Po');
$countTranslations = 13;
$countTranslated = 10;
$countHeaders = 13;
$countHeaders = 15;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -90,7 +90,7 @@ public function testPo3()
$translations = static::get('po3/input', 'Po');
$countTranslations = 8;
$countTranslated = 8;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -126,7 +126,7 @@ public function testBlade()
$translations = static::get('blade/input', 'Blade');
$countTranslations = 11;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -162,7 +162,7 @@ public function testJed()
$translations = static::get('jed/input', 'Jed');
$countTranslations = 13;
$countTranslated = 10;
$countHeaders = 10;
$countHeaders = 12;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -198,7 +198,7 @@ public function testJsCode()
$translations = static::get('jscode/input', 'JsCode');
$countTranslations = 7;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -234,7 +234,7 @@ public function testJs2Code()
$translations = static::get('jscode2/input', 'JsCode');
$countTranslations = 4;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -269,7 +269,7 @@ public function testPhpCode()
$translations = static::get('phpcode/input', 'PhpCode');
$countTranslations = 12;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -309,7 +309,7 @@ public function testPhpCode2()
]);
$countTranslations = 13;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -347,7 +347,7 @@ public function testPhpCode3()
]);
$countTranslations = 2;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -383,7 +383,7 @@ public function testTwig()
$translations = static::get('twig/input', 'Twig');
$countTranslations = 10;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -423,7 +423,7 @@ public function testVueJs()
$translations = static::get('vuejs/input', 'VueJs');
$countTranslations = 31;
$countTranslated = 0;
$countHeaders = 8;
$countHeaders = 10;

$this->assertCount($countTranslations, $translations);
$this->assertCount($countHeaders, $translations->getHeaders());
Expand Down Expand Up @@ -466,7 +466,7 @@ public function testPhpCode4()
'domainOnly' => true,
]);

$countHeaders = 9;
$countHeaders = 11;
$countTranslated = 0;
$countTranslations = 4;

Expand Down