I have java/spring based web application with front end in JSP/HTML/JS/Jquery.
We already have spring based i18n support.
- In JSP labels are coming from property files.
- 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
-
1Is there something you can search for in the source code?Robert Harvey– Robert Harvey2018年01月27日 17:24:47 +00:00Commented Jan 27, 2018 at 17:24
-
No there is no specific pattern. Right now I can think of going through each fileuser3198603– user31986032018年01月28日 10:48:13 +00:00Commented 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:
/\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.
-
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– Laiv2018年01月29日 07:22:52 +00:00Commented 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– ChrisF2018年01月29日 09:18:52 +00:00Commented 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– Laiv2018年01月29日 09:45:32 +00:00Commented Jan 29, 2018 at 9:45
Explore related questions
See similar questions with these tags.