0

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

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

1 Answer 1

1

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

/\v"([^"]|\n)*"

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.

answered Jan 28, 2018 at 18:29
3
  • 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. Commented 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. Commented 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 :-) Commented Jan 29, 2018 at 9:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.