Skip to content

[Translation] [Xliff] Support for <note> #10939

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

Closed
wants to merge 8 commits into from

Conversation

jderusse
Copy link
Member

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #10550
License MIT
Doc PR n/a

The purpose of this PR, is to avoid that the automated translation update (app/console translation:update) remove the note tags from XLIFF files.

Not sure if using the metadata bag is a good thing or if I should have add a "note" property in MessageCatalogue. What do you think ?

@@ -33,6 +33,9 @@ protected function processDomain($domain)
if ($this->target->has($id, $domain)) {
$this->messages[$domain]['all'][$id] = $message;
$this->result->add(array($id => $message), $domain);
if (!is_null($keyMetadata = $this->source->getMetadata($id, $domain))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use comparison against null instead of is_null : if (null !== $keyMetadata = $this->source->getMetadata($id, $domain)) {

@jderusse
Copy link
Member Author

@fabpot Is metadata the right place to store notes ?

I didn't found documentation about purpose of messageCatalogue's metadata, I wonder, if I should store only scalar values (as implemented: array of hash) or if I can store XliffNoteCollection containing XliffNote objects ?

@@ -32,6 +32,9 @@ protected function processDomain($domain)
foreach ($this->source->all($domain) as $id => $message) {
$this->messages[$domain]['all'][$id] = $message;
$this->result->add(array($id => $message), $domain);
if (null !== ($keyMetadata = $this->source->getMetadata($id, $domain))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parenthesis around the assignment should be removed (same below).

@fabpot
Copy link
Member

fabpot commented Jun 16, 2014

Looks good to me 👍

$catalogue->setMetadata((string) $source, array('notes' => $notes), $domain);
}

if (!isset($translation->target)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no target, the translation is not added to the catalogue. does it make sense to add the metadata in such case ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Even in DiffOperation and MergeOperation the entry (and the metadata) will not be used if there is no translation

Jérémy Derussé added 8 commits June 16, 2014 22:36
Parse XLIFF files to extract "note" property and store them into the messageCatalogue metadata
Retrieves notes from messageCatalogue metadata, and store them into xliff file
Some information contained in source catalogue (like Xliff's notes) have to be write in target catalogue.
@romainneutron
Copy link
Contributor

👍

@fabpot
Copy link
Member

fabpot commented Jun 17, 2014

Thank you @jeremy-derusse.

@fabpot fabpot closed this in 6587b39 Jun 17, 2014
@jderusse jderusse deleted the load-and-dump-xliff-notes branch May 1, 2017 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants