schmittjoh / JMSTranslationBundle

Puts the Symfony2 Translation Component on steroids
http://jmsyst.com/bundles/JMSTranslationBundle
427 stars 291 forks source link

Desc is not overrwrite on extraction #101

Open tkleinhakisa opened 11 years ago

tkleinhakisa commented 11 years ago

I have made a custom extractor to pull translation key strings from DB

In the sql table there is a field with the key and a field with the description (think annotation @DESC)

in the extractor i do

$catalogue = new MessageCatalogue();

$result = .....

foreach ($result as $res) {
    $message = new Message($res['tradKey'], 'messages');
    $message->setDesc($res['tradDesc']);
    $catalogue->add($message);
}
return $catalogue;

if i fill my tables without the description and extract i get in the files:

<trans-unit id="5eb0cb20f24177a19746b8460b33fe56eb3899ba" resname="this.is.the.key">
        <source>this.is.the.key</source>
        <target state="new">this.is.the.key</target>
</trans-unit>

if, after that, i fill my tables with description and extract, i get the same thing in the file, but i'd expect to have :

<trans-unit id="5eb0cb20f24177a19746b8460b33fe56eb3899ba" resname="this.is.the.key">
        <source>my new description that i just wrote</source>
        <target state="new">my new description that i just wrote</target>
</trans-unit>

I think a newly added description should overwrite the old one but the mergeExisting method in the Message.php does it the other way

Is it a wanted behavior ? if yes, can someone explain it to me ?

Thanks for the bundle and coming answer

kyle-ilantzis commented 10 years ago

I think it is simply because the code to detect changes is not implemented.

https://github.com/schmittjoh/JMSTranslationBundle/blob/master/Translation/Comparison/CatalogueComparator.php#L69

The comparison function does nothing when there exists an old messages and a new extracted message with the same id.

Nyholm commented 8 years ago

I know it was a long time ago you posted this issue. Do you still experiencing this? Or is it fixed in the latest version of the bundle?