rquinio / l10n-maven-plugin

:abcd: Maven plugin to validate localization resources in Java properties files
MIT License
3 stars 1 forks source link

Detect duplicated keys in property file #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If a file has multiple copies of the same line it is a recipe for bugs down the 
line. I believe the second copy gets loaded so a developer may see an issue, 
change the text and not know why the value isn't getting changed in final 
build. Apparently the behavior isn't well defined 
(http://stackoverflow.com/questions/12558210/duplicate-keys-in-java-util-propert
ies) so this could even lead to different results depending on platform! 

This link provides a pretty decent method of doing the detection:
http://stackoverflow.com/questions/1779196/tool-to-find-duplicate-keys-and-value
-in-properties-file

Example:

group.page.deleteError=This group is a target for a scheduled event. Remove the 
group from the event and try again.
group.page.BILLING=Billing
group.page.deleteError=Delete Instructions

Should error on second instance.

Nice tool BTW, found a number of issues in my files I wouldn't have ever seen. 
Only reason I saw the duplicate lines was intellij pointing them out.

Original issue reported on code.google.com by sam.hend...@gmail.com on 12 Nov 2013 at 5:46

GoogleCodeExporter commented 9 years ago
Glad the plugin was helpful to you !

Nice trick for the detection, I've added a validator to cover those nasty 
duplicate keys.

Original comment by romain.q...@gmail.com on 14 Nov 2013 at 10:20

pubsrc commented 3 years ago

A simple way to to detect duplicate values in property file is to use node unival pacakage if you use vscode there is also an extensionsion unival. it detectes duplicates within a file or group of files

unival clie: npm install unival Extension: https://marketplace.visualstudio.com/items?itemName=pubsrc.unival