Presentation is loading. Please wait.

Presentation is loading. Please wait.

Internationalization in the Java Stack Matt Wheeler.

Similar presentations


Presentation on theme: "Internationalization in the Java Stack Matt Wheeler."— Presentation transcript:

1 Internationalization in the Java Stack Matt Wheeler

2 Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Introduction to Spring – Basic Java and XML skills – Installed LdsTech IDE (or other equivalent – good luck there ;)

3 Overview Stack provided internationalizaton tools Message source expression language resolver JS Message source Internationalization best practices Internationalization testing Dynamic pseudo translation

4 Expression Language Resolver Provide message resolver can be utilized in EL http://code.lds.org/maven- sites/stack/module.html?module=web- spring/#El_Message_Source ${messages['abc.def.ghi']}

5 JavaScript Source JS Configuration messageSourceController

6 MessageSource with JS Usage in a JSP page alert(msgs['abc']);

7 Some I18n Best Practices Externalize ALL translatable text Do not concatenate translations Create duplicate / separate resources Avoid text in images

8 Externalize ALL Text Page label - "Name: “ "Name:" including the colon, and not just "Name" externalized – Otherwise require contatenation - the “Name”coming out of the bundle with : on the page : and associated formatting can be different in different languages – It might also be in a different order

9 Do NOT Concatenate Translations For example: Attempted usage key1=Someone named key2=likes hiking. ${messages['key1']} Billy ${messages['key2']}

10 More Correct Way Create a single string with replaceable parameters Sentence maintains context – Parameters can be moved around to accommodate language grammar For example: And then it will be used as follows: key=Someone named {0} likes hiking.

11 Create Separate Resources Counter intuitive to code reuse concept Same English strings should not be shared Within the same application, or even the same page Create a separate key value pair for each occurrence Words change based on context Concept of masculine and/or feminine, age classes, … Or usage Similar English words may not be similar in another language

12 Avoid Placing Text in Images An image that contains text will require a new image for each language It will also require a custom way to load the image Impose the text over the image, using.css or other ingenious alternative – Then the text can be stored in the resource bundles with all other strings – And it won’t require a new image for each language

13 I18n Testing (Dynamic Pseudo Translation) Configured to translate for specified locales Simplifies testing – Expansion – Special characters – Completeness – zz locale http://code.lds.org/maven- sites/stack/module.html?module=web- spring/#Pseudo_Translation_Message_Source_Faca de

14 Dynamic Pseudo Translation The trick (delegate) <bean id="delegatingMessageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> classpath:messages

15 Lab

16 Other Considerations Avoid cultural references Avoid sports analogies Avoid colloquialisms Non-translatable names Avoid animal / hand gesture icons Understand color connotations by culture – Blue is safest color generally

17 asdf

18 Lab 1: Internationalize a page https://tech.lds.org/wiki/Introduction_to_Spring#L ab_2_Dependency_Injection

19 Credit where credit is due http://www.ibm.com/developerworks/java/tutor ials/j-i18n/section2.html


Download ppt "Internationalization in the Java Stack Matt Wheeler."

Similar presentations


Ads by Google