Plugin for automatic property file sorting
Answered
We are developing a plugin to sort property files by keys. Currently we can invoke the sorting manually, but the resource bundle editor will be used by non-tech guys as well.
Is there a way to get notified when a file was modified in order to perform the sorting?
Very happy to get a poke in the right direction :-)
Please sign in to leave a comment.
Hi, Andreas,
you can use simply use PsiTreeChangeListener (sure if a modification was made inside properties files editor).
BTW we already have an inspection AlphaUnsortedPropertiesFileInspection to detect such cases + Resource Bundle Editor preserves sorting order if it's possible while editing.
Hi Dmitry,
wow that was fast. Thanks for pointing us in the right direction.
I tried the inspection and it looks like this is exactly what we are after :-)
Thanks!
BTW is your plugin available for download? It sounds like something I could use!
Hubert, it's already available in IntelliJ IDEA installation when properties support plugin is enabled.
I use Properties Support plugin already but it doesn't allow me to sort properties.
Hubert, search for "Properties File or Resource Bundle is Alphabetically Unsorted" inspection in inspection settings. It should be disabled by default.
Can you sort all resource files in a project in one go, instead of doing the sort per resource bundle?
We use lokalise.com as a service for translation of property files and integration with Github.
The problem with the this inspection is that is not possible to change the sort order (alphabetically, ascii)
In the following sample, the last line would be placed first by the inspection...