learn to internationalize your applications - sun tech days 2009
DESCRIPTION
Hands on Lab Session on How to internationalize your applications using java, JavaFX, AJAX, Portlets.TRANSCRIPT
![Page 1: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/1.jpg)
Learn to Internationalize your Java, JavaFX, AJAX and Portlet Applications
Shankar Gowda & Shrinath HedgeGlobalization EngineeringSun Microsystems, Inc.
![Page 2: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/2.jpg)
2
Agenda> Globalization Overview> What's with acronyms and definitions ?> How do they differ and relate ?> Introducing Internationalization(i18n) in various technologies> Language Exercises (100 mins)
– Exercise 0: Setup Lab Environments– Exercise 1: Internationalize your Java application– Exercise 3: Internationalize AJAX Web application– Exercise 4: Internationalize Portlet application– Exercise 2: Internationalize JavaFX application
> Tools, Summary and References
![Page 3: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/3.jpg)
3
Globalization acronymsGlobalization [G1 1 n]
“Globalization addresses the business issues associated with taking a product global. In the globalization of high-tech products this involves integrating localization throughout a company, after proper internationalization and product design, as well as marketing, sales, and support in the world market.”
Internationalization [i1 8n]“Internationalization is the process of generalizing a product so that it can handle multiple languages and cultural conventions without the need for re-design. Internationalization takes place at the level of program design and document development.”
Localization [L10n]“Localization involves taking a product and making it linguistically and culturally appropriate to the target locale (country/region and language) where it will be used and sold.”
Translation ===> T9n
![Page 4: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/4.jpg)
4
How do they differ and relate ?• Globalization at the architecture level• Internationalization (i1 8n) enables Localization• An expert in i1 8n may not be an expert in l1 0n• I18n (code) + l10n(linguistic) + T9n (translation)
= G11n (process)
![Page 5: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/5.jpg)
5
Internationalization support in Java➢ Java Platform is Internationalized
● Extensive library of classes and functions
● I18n support comes for free or at very little cost
● Built-in I18n support for over 70 languages
➢ All text in a running Java program is Unicode
![Page 6: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/6.jpg)
6
Concept of Resource Bundle
![Page 7: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/7.jpg)
7
Example Code: Before Internationalization
System.out.println(“Hello”);
System.out.println(“Sun Tech Days”);
System.out.println(“Hyderabad”);
![Page 8: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/8.jpg)
8
Example Code: After Internationalization
Locale myLocale = new Locale(myLanguage, myCountry);
ResourceBundle messages = ResourceBundle.getBundle(“messageBundle, myLocale);
System.out.println(messages.getString(“greeting”));System.out.println(messages.getString(“event”));System.out.println(messages.getString(“place”));
Your Resource Bundle property catalog file will have,greeting=Helloevent=Sun Tech Daysplace=Hyderabad
![Page 9: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/9.jpg)
9
Introduction to AJAX > AJAX = acronym for
Asynchronous JavaScript and XML– Browser client uses JavaScript to Asynchronously– get XML data from a server and update page– dynamically without refreshing the whole page
> Why is AJAX so popular ?– Increase Usability of Web Application– Save Bandwidth– Download only data you need– End user Sequence and Faster interfaces
> Side effects of AJAX ?– Breaks back button support– URL's don't change as state changes– Cross Browser Issues can be a pain
![Page 10: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/10.jpg)
1 0
User Interface: Traditional Web Vs AJAX
![Page 11: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/11.jpg)
1 1
Traditional Web AJAX within a browser, there is AJAX engine
![Page 12: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/12.jpg)
1 2
AJAX Internationalization• Server Side: By setting the appropriate Request
and Response Object to a right encoding in Servlet controller> In doGet method
– request.setCharacterEncoding(“UTF-8”);> In sendResonse method
– response.setContentType(“text/xml; charset=utf-8”);
> Using Resource Bundle for externalizing messages to property files and naming them to appropriate locale variant.
• Client Side: By setting your browser to UTF-8 encoding.
![Page 13: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/13.jpg)
1 3
Introducing Portlet Application> Specialized Web application that
provides value-added services like,– Personalization, Single Sign-On,
Content Aggregation, Dynamic Drag and Drop, Work From Desktop, Search& Tagging.
> Portlet is a piece of markup called as 'Fragment'
> A Portal Application can have multiple portlets.
– Window functionalities like, minimize, maximize, configure, close..etc
> Portal Administration for Role, Look & Feel, Permissions, SOA, JAI
> Includes Wikis, Message Boards, Blogs, Email, IM, Activity Tracking, Calendar, etc..
![Page 14: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/14.jpg)
1 4
Hindi Portal Application
![Page 15: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/15.jpg)
1 5
Internationalizing your Portlet> Server Side: By setting the appropriate Resquest and
Response Objects to right encoding in Servlet/JSP controller.
– Adding locale support in your portlet.xml<supported-locale>hi</supported-locale>
– JSP Page Directive <%page contentType=”text/html; charset=UTF-8”%><%page pageEncoding=”UTF-8” %>
– Using JSTL FMT library<% taglib uri=”http://java.sun.com/jsp/jstl/fmt” prefix=”fmt” %>
– Setting Resource Bundle<fmt.setBundle basename=”PackageName.BundleName” />
– Calling the tag lib in your JSP page<fmt:message key=”name”/>
> Client Side: Set your browser encoding to UTF-8.
![Page 16: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/16.jpg)
1 6
> Install Java SE 6 update 10 or above> Install NetBeans 6.5 with GlassFish V2/V3
Let us start the LAB with Exercise 0
> Copy i18nHOL.zipi18nHOL.zip and unzip
– Will create i18nHOL directory = <lab_root><lab_root>
– It contains the following:– Start with index.html index.html– Exercises directory like
![Page 17: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/17.jpg)
1 7
Excrcise 1: Learn to Internationalize your Java Application
![Page 18: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/18.jpg)
1 8
Exercise 3: Learn to Internationalize your AJAX enabled Web Application
![Page 19: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/19.jpg)
1 9
Exercise 4: Learn to Internationalize your Portlet Application
![Page 20: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/20.jpg)
20
Lastly, let us take to JavaFX Lab Session
![Page 21: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/21.jpg)
21
● JavaFX platform● JavaFX Desktop ● JavaFX Mobile and JavaFX TV ● Other devices and screens to follow
● Tools Suite● JavaFX Developer (Plug-ins for IDEs, Media
converters, RAD tools)● JavaFX Designer (Authoring, Video
Encoding)● Suite of Applications build on JavaFX
● JavaFX Content, Applications & Services
JavaFX OverviewFX
![Page 22: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/22.jpg)
22
Single Virtual Machine/ byte code
![Page 23: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/23.jpg)
23
JavaFX Script Programming Language > Declarative, statically-typed scripting language> Facilitates rapid GUI development> Many cool, interesting language features > Runs on Virtual Machine for the Java™ platform> Deployment options same as Java programs> Fully utilizes Java class libraries behind the scenes> For content designers and Media engineers > Supports primitive types like, String, Boolean, Number,
Integer, Duration.> Supports Objects, Multiple Inheritance and any Java
Objects can be used in JavaFX.
![Page 24: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/24.jpg)
24
Comparision of Java, Swing and JavaFX
![Page 25: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/25.jpg)
25
Introducing Internationalization in JavaFX> Creating a Locale Object> Setting the default locale
> Create Resource Bundle property file as “Main_hi_IN.fxproperties”
> Resource bundle messages are called just by prefixing with '##'
> Reduces complexity! Compared to Java Resource Bundle
![Page 26: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/26.jpg)
26
Internationalizing Dates in JavaFX> Supports Java printf-style formats> Uses same Formatter as Java> POSIX standard strftime spec.
![Page 27: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/27.jpg)
27
Internationalizing of Dates in JavaFX• Formats
– %tx – Locale's appropriate date representation– %tX – Locale's appropriate time representation– %tg – The last two digits of the week-based year (ISO 8601)– %tG – Week-based year (ISO 8601)– %tu – Day of week ( Monday is 1) [ 1,7 ]– %tV – ISO 8601 Week number of the Year.
![Page 28: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/28.jpg)
28
Looking at locale based sorting for JavaFX> Create a List of words> Create the Instance of Collator by specifying the
Locale.> Define the function for Sorting and displaying the List
of words.
![Page 29: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/29.jpg)
29
Locale based Sorting using Collator> In sort function we will call Collections.sort, that sorts
the list of words in ascending order by giving the words list and strength of the collator as arguments.
> Append the output to a variable.
> Display as,
![Page 30: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/30.jpg)
30
Exercise 2: Learn to i18n JavaFXSphere • Install, Configure Lab environment• Creating a FirstJavaFXSphere Application• Internationalizing the code of FirstJavaFXSphere
application• Externalizing the messages to Main_hi_IN.fxproperties• Localizing in Hindi
![Page 31: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/31.jpg)
31
Internationalization References• Sun Software Globalization
– http://developers.sun.com/techtopics/global/• Software Globalization - Architecture, Design,Testing
– http://developers.sun.com/techtopics/global/technology/arch/• Software Globaliation- Sun Java Enterprise System
– http://developers.sun.com/techtopics/global/products_platforms/jes/• Sun Software Product Internationalization Taxonomy
– http://developers.sun.com/dev/gadc/des_dev/i18ntaxonomy• Java Internationalization
– http://java.sun.com/javase/technologies/core/basic/intl/• Subscribe to Software globalization NewsLetter
– http://developers.sun.com/dev/gadc/subscribe/index.html• Technical articles on Java Internationalization
– http://java.sun.com/developer/technicalArticles/Intl/• Java Internationalization Tutorial
– http://java.sun.com/docs/books/tutorial/i18n/index.html
![Page 32: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/32.jpg)
32
JavaFX References
• http://javafx.com/• https://openjfx.dev.java.net/• http://openjfx-compiler.dev.java.net • http://scenegraph.dev.java.net• http://java.sun.com/javafx/• http://java.sun.com/javafx/tutorials/project_nile_integrating_graphics/• http://openjfx.java.sun.com/current-build/doc/index.html
![Page 33: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/33.jpg)
33
AJAX References• The BluePrints Solutions catalog on AJAX
– https://bpcatalog.dev.java.net/nonav/solutions.html• AJAX Q & A
– https://blueprints.dev.java.net/ajax-faq.html• Asynchronous JavaScript Technology and XML (AJAX) with Java 2 Platform,
Enterprise Edition– http://java.sun.com/developer/technicalArticles/J2EE/AJAX/Intro_Ajax
_PageAuthors.pdf• AJAX Frameworks
– http://ajaxpatterns.org/wiki/index.php?title=AJAXFrameworks• AJAX Library and Frameworks Comparison
– http://wiki.osafoundation.org/bin/view/Projects/AjaxLibraries• AJAX Developer Resource Center
– http://developers.sun.com/ajax/• JavaScript Developer Site
– http://java.sun.com/javascript
![Page 34: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/34.jpg)
34
Portlet References
• http://javafx.com/• https://openjfx.dev.java.net/• http://openjfx-compiler.dev.java.net • http://scenegraph.dev.java.net• http://java.sun.com/javafx/• http://java.sun.com/javafx/tutorials/project_nile_integrating_graphics/• http://openjfx.java.sun.com/current-build/doc/index.html
![Page 35: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/35.jpg)
35
Q & A
![Page 37: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/37.jpg)
37
Backup of JavaFX
![Page 38: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/38.jpg)
38
JavaFX: Command Line Development• include <javafx-sdk>/bin in PATH• javafxc to compile• javafx to run• Relevant library files in <javafx-sdk>/lib are
automatically included in classpath as necessary. Rest can be included with the -classpath option> With packages
● javafxc -d . firstjavafxsphere/Main.fx● javafx firstjavafxsphere.Main
> Without packages● javafxc Main.fx● javafx Main
![Page 39: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/39.jpg)
39
JavaFX: FirstJavaFXSphere.jnlp (applet)<jnlp href="test.jnlp"> <information>... </information> <resources> <j2se version="1.6+" href= "http://java.sun.com/products/autodl/j2se" /> <jar href="FirstJavaFXSphereApplet.jar" main="true" /> <jar href="javafxrt.jar" /> <jar href="javafxgui.jar" /> <jar href="javafx-swing.jar" /> <jar href="Scenario.jar" /> </resources> <applet-desc name=test main-class="javafx.application.Applet" width=500 height=500> </applet-desc></jnlp>
![Page 40: Learn to Internationalize your Applications - Sun Tech Days 2009](https://reader033.vdocuments.us/reader033/viewer/2022051819/54c71c924a7959353d8b45dc/html5/thumbnails/40.jpg)
40
JavaFX: FirstJavaFXSphere.html (Applet call)<html> <head> <title>FX Script Applet Test</title> </head> <body bgcolor="#000000"> <h1>FX Script Applet Test</h1> <center> <applet width="640" height="480"> <param name="jnlp_href" value="FirstJavaFXSphere.jnlp"> <param name="ApplicationClass" value="FirstJavaFXSphereApplet"> </applet> </center> </body></html>