Skip to content

Adding a new Language to Shepherd

ismisepaul edited this page Sep 23, 2015 · 5 revisions

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;

  1. A user selects a language from the drop down
  2. The application receives the value from the browser header "Accept-Language"

Setting Up

  1. 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.

  2. After you open the application in Eclipse the .properties file 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;

zf8ed52591579339e590e0726c7b24009f3ac54cdff1b81a65db1688d86efb3a.properties

and all other translations is a copy of this file with an underscore and language code;

  • Irish: zf8ed52591579339e590e0726c7b24009f3ac54cdff1b81a65db1688d86efb3a_ga.properties
  • Spanish: zf8ed52591579339e590e0726c7b24009f3ac54cdff1b81a65db1688d86efb3a_es.properties
  • China: zf8ed52591579339e590e0726c7b24009f3ac54cdff1b81a65db1688d86efb3a_zh.properties

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 = &lt;SCRIPT&gt;<a>alert(&#39;XSS&#39;)</a>&lt;/SCRIPT&gt;

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".

You can’t perform that action at this time.