Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tools to help with Internationalization of Strings in JSP

Are there any tools to assist with the internationalization of Strings within JSP files?

Most IDEs (for example, NetBeans) offer such a feature for Java code. However, in the case of NetBeans, no such feature exists for JSP files.

With gettext, for example, there is are various tools out there that assist with extracting text Strings from code. Something similar for JSP would be great!

like image 401
myabc Avatar asked Oct 18 '25 15:10

myabc


1 Answers

I hope no-one minds if I bump an old question...

When faced with the same problem, I put together (a) a method for localising strings in JSPs in the Gettext style (keeping English in the source JSP) and (b) an Ant task which can find such strings in JSPs and generate a Gettext POT file.

(a) is provided by WebGettext, which provides an EL resolver for expressions such as ${messages["Hello {0}"][username]}. The resolver looks up a translation, for the requesting user's locale, and substitutes any parameters using MessageFormat.

(b) is provided by Regex2PotTask, which is a bit like xgettext but for a configurable regex expression rather than C, Java, Perl, etc, function calls such as gettext("my string").

Tennera's home page is here.

Example JSP project - see RUNNING.txt

It's all a bit rough at present, but I think the basics are all there. If someone expresses interest, I might even be motivated to document it "properly"...

like image 108
seanf Avatar answered Oct 21 '25 13:10

seanf