Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Translator] Add sources when dumping qt files #31248

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

Merged
merged 1 commit into from
Apr 29, 2019
Merged
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
11 changes: 11 additions & 0 deletions 11 src/Symfony/Component/Translation/Dumper/QtFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti

foreach ($messages->all($domain) as $source => $target) {
$message = $context->appendChild($dom->createElement('message'));
$metadata = $messages->getMetadata($source, $domain);
if (isset($metadata['sources'])) {
foreach ((array) $metadata['sources'] as $location) {
fabpot marked this conversation as resolved.
Show resolved Hide resolved
$loc = explode(':', $location, 2);
$location = $message->appendChild($dom->createElement('location'));
$location->setAttribute('filename', $loc[0]);
if (isset($loc[1])) {
$location->setAttribute('line', $loc[1]);
}
}
}
$message->appendChild($dom->createElement('source', $source));
$message->appendChild($dom->createElement('translation', $target));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,26 @@ class QtFileDumperTest extends TestCase
public function testFormatCatalogue()
{
$catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar'], 'resources');
$catalogue->add(['foo' => 'bar', 'foo_bar' => 'foobar', 'bar_foo' => 'barfoo'], 'resources');
$catalogue->setMetadata('foo_bar', [
'comments' => [
'Comment 1',
'Comment 2',
],
'flags' => [
'fuzzy',
'another',
],
'sources' => [
'src/file_1',
'src/file_2:50',
],
], 'resources');
$catalogue->setMetadata('bar_foo', [
'comments' => 'Comment',
'flags' => 'fuzzy',
'sources' => 'src/file_1',
], 'resources');

$dumper = new QtFileDumper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public function testLoad()
$resource = __DIR__.'/../fixtures/resources.ts';
$catalogue = $loader->load($resource, 'en', 'resources');

$this->assertEquals(['foo' => 'bar'], $catalogue->all('resources'));
$this->assertEquals([
'foo' => 'bar',
'foo_bar' => 'foobar',
'bar_foo' => 'barfoo',
], $catalogue->all('resources'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
Expand Down
11 changes: 11 additions & 0 deletions 11 src/Symfony/Component/Translation/Tests/fixtures/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@
<source>foo</source>
<translation>bar</translation>
</message>
<message>
<location filename="src/file_1"/>
<location filename="src/file_2" line="50"/>
<source>foo_bar</source>
<translation>foobar</translation>
</message>
<message>
<location filename="src/file_1"/>
<source>bar_foo</source>
<translation>barfoo</translation>
</message>
</context>
</TS>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.