I have java/spring based web application with front end in JSP/HTML/JS/Jquery.

We already have spring based i18n support.

  1. In JSP labels are coming from property files.
  2. html/browser download the js file specific to locale which contains validatins messages.

Problem for both above points , half of the labels/messages are hardcoded in jsp/js files instead of picking them up from resource bundle.Now we need to replace those harcoded labels/messages with resource bundle/ js files.

I can think of only manual solution where developer need to go through each jsp/js files and see if any hard coded message exist. If yes pick it fromresource bundle. Is there any better strategy to automate this task where I can get list of all hardcoded messages in jsp and js file with some utility/third party plugin etc

  • 1
    Is there something you can search for in the source code? Jan 27, 2018 at 17:24
  • No there is no specific pattern. Right now I can think of going through each file Jan 28, 2018 at 10:48

1 Answer 1


I almost hate to suggest this given my dislike of regexes, but would a regex search for quoted strings work:


I found this one here - Regex to search double quoted strings on multiple lines

This should give you a complete list of files that you'll need to edit.

Unfortunately, there's nothing that can automate the actual replacement of the string with a call/reference to the resource bundle.

  • The regex should look into tags. Otherwise, the regex is going to return almost all the jsps, due to tag"s attributes also have quoted text.
    – Laiv
    Jan 29, 2018 at 7:22
  • @Laiv ah. Well, there you reach the limit of my regex knowledge ;) It's probably possible to modify the regex to look for quoted strings inside tags, but I'm not sure how to go about that.
    – ChrisF
    Jan 29, 2018 at 9:18
  • It's a nightmare... As you commented, this is a job to do manually. Also a job for QA :-)
    – Laiv
    Jan 29, 2018 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.