[forge-dev] Plug-in for collect key properties list from source code with regular expressions

Pablo Palazon pablo.palazon at gmail.com
Mon May 7 17:16:05 EDT 2012


Hi everybody!,

I'd like to present a plug-in for collect key properties and be added to
properties files (https://github.com/ppalazon/rxlist-forge). Basic, this
plug-in search regular expressions in the content of a group of files, for
example all java source code (*.java).

I use this plug-in for collect multilingual key used in java and xhtml
code. For example:

facesmessages.info(messages.getMessage("command.success.message"))

or

<h:outputText value="#{messages['person.preffix']}, #{user.lastname}"/>

Normally, I wrote business code and I don't worry about write this in a
multilingual properties file. Later, I must review all code for collect
used multilingual keys. This is tedious when you have many sources files,
and you have some keys in properties file.

For install: forge git-plugin git://github.com/ppalazon/rxlist-forge.git

This plug-in only contains a commands with 3 arguments

--rxProperties -> regular expression for find properties files
(Messages.*.properties)
--rxSearchFiles -> regular expression for say which files explore (.*.java,
.*.xhtml, etc)
--regexp -> regular expression for describe where is keys
(messages.getMessage\(''(.*?)''\), messages.getMessage\('(.*?)'\))

Examples:
rxlist --rxProperties messages_.*.properties --rxSearchFiles .*.java
--regexp Componente1.getMessage\(''(.*?)''\) - (I use 2 simple quotes,
don't double quote)
rxlist --rxProperties messages_.*.properties --rxSearchFiles .*.xhtml
--regexp messages.getMessage\('(.*?)'\) - With simple quotes

All regular expression is based on Java Pattern (
http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html)

This plugin insert non declared properties keys in properties files, and
insert a default content (founded.key=>>founded.key).

If you would like to see this in action, there are some test files in
src/test/resources with 2 properties files, 1 java file and 1 xhtml file.
You can open original properties files, and search updated properties files
with test (RegExpListPluginTest) in a generated directory.

I used this plug-in in a web application, and It's useful when you'd been
used a lot of properties key for multilingual. I'd like to listen you any
suggest, error or improve for this plug-in, or maybe this help you for
create new plug-in for forge. Thanks you so much for this platform, it was
very easy and quick develop this plug-in.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20120507/98cb75bf/attachment-0001.html 


More information about the forge-dev mailing list