Give a hint if the same ID occurs more than once
ftaffelt opened this issue · 3 comments
During a faulty merge in our source versioning system, duplicate ID's occurred in the messages files for one language. This condition was not detected for a long time and led to a long search for causes on different levels before the problem was found in duplicate message IDs.
I know the angular property "i18nDuplicateTranslation" but this doesn't seem to give a warning or error message here either.
Would it be possible to integrate a check for duplicate ID's?
@ftaffelt what would be the desired result?
Some logging vs. error + exit vs. remove duplicates?
(not really sure if / how this fits into this lib - some angular option affecting/aborting the build like i18nDuplicateTranslation would seem a better fit?)
Good question. I think that an automatic removal of duplicate values is not possible, because you don't know what is the right one to keep. Such a warning would be helpful.
In my case, I wrote an XSL stylesheet that embeds the duplicate values in the transunit:
<trans-unit duplicates="2" id="1220142055650021084" datatype="html">
<source>Change number of items</source>
<target state="new">Change number of items</target>
<note priority="1" from="description">change page size title</note>
<note priority="1" from="meaning">Resultset</note>
<duplicates>
<target state="new">Change number of items</target>
<target state="new">Change number of hits</target>
</duplicates>
</trans-unit>
Then it is a manual/human job to correct the values and remove the entries under duplicates/values again.
But maybe you are right and the topic is a bit too special and not in the scope of this lib.
After some thought, this can probably be done with a "simple" bash command (not tested) - which could be a verification step in your CI:
grep -Eo 'id="[^"]+"' messages*.xlf | sort | uniq -d
Based on this, I'd rather keep this additional complexity out of this lib.
In case you - or others - think this is relevant to more users, please reopen/comment!