Adding a new Language to Shepherd
Translation is accomplished utilising the Java JSTL library under under
lib/jstl-1.2.jar in which key value pairs are stored in
.properties files within the i18n package in the Security Shepherd Project. The key remains the same across all
.properties files and the value is the translation in a particular language.
The language of the application is changed/set in the user's session in two ways;
- A user selects a language from the drop down
- The application receives the value from the browser header "Accept-Language"
You should have your Eclipse and MySQL set up for Security Shepherd properly, this allows you to run the application. This Youtube video can help you to set up https://www.youtube.com/watch?v=uWk0NOSpyQc.
After you open the application in Eclipse the
.propertiesfile for translation is located under OwaspSecurityShepherd->src->i18n-> (challenges,cheatsheets,lessons,moduleGenerics and servlets).
Tip: To view the project in a user friendly way click the down triangle (beside the project list) and select Package Presentation-> Hierarchical.
3.Now you can start!
Working with Properties Files
.properties files are key value pair documents used for translation. English text is stored in files that contain no underscore;
and all other translations is a copy of this file with an underscore and language code;
Within each of these files is a key and a value which looks like this;
title.question.xss = What is Cross Site Scripting (XSS)?
example.xss.1 = <SCRIPT><a>alert('XSS')</a></SCRIPT>
Creating Properties Files
Now create a new
.properties file firstly for English if it doesn't exist under the corresponds directory where your JSP or Servlet is located. For instance if your JSP is under src/jsp/challenges/HASH.jsp store your
.properties file under src/i18n/challenges/HASH.properties
For files that are in a language other than english create a copy of the English file and add the underscore and country code as outlined in the section "Working with Properties Files".