250 likes | 265 Views
Sakai: Localization & Internationalization. Beth Kirschner University of Michigan beth.kirschner@umich.edu. Localization (l10n) versus Internationalization (i18n).
E N D
Sakai: Localization & Internationalization Beth Kirschner University of Michigan beth.kirschner@umich.edu
Localization (l10n) versus Internationalization (i18n) • Localization of a web interface is usually limited to isolating the language dependencies such that they can be easily translated. • Internationalization of a web interface takes into account many aspects beyond strict translation of the text, such as cultural differences, space allocation and formatting. • Sakai needs to consider both.
Enabling Sakai Localization • Velocity templates • Java Server Faces templates • Java code • Static HTML (e.g. help text) • Database information
Sakai Presentation Environments Sakai Portal Sakai Velocity Support Layer Sakai JSF Widget Set The Sakai Legacy Environment The Sakai Tool Environment Velocity Templates Java Server Faces in JSP Sakai Framework APIs Sakai Legacy Tools Java Tool Logic Java Beans Sakai Legacy Services Sakai Application Services
Localizing Velocity Templates (before) <form name="viewForm" class="toolbarForm" method="post" action="#toolForm("CalendarAction")"> <input type="hidden" name="eventSubmit_doView" value="view" /> View: <select name="view" size="1" tabindex="3" onchange="blur();document.viewForm.submit();"> #foreach ($view in ["Calendar by day", "Calendar by week", "Calendar by month", "Calendar by year", "List of events"])
Localizing Velocity Templates (after) <form name="viewForm" class="toolbarForm" method="post" action="#toolForm("CalendarAction")"> <input type="hidden" name="eventSubmit_doView" value="view" /> $tlang.getString(“view.view”) <select name="view" size="1" tabindex="3" onchange="blur();document.viewForm.submit();"> #foreach ($view in ["$tlang.getString('java.byday')", "$tlang.getString('java.byweek')", "$tlang.getString('java.bymonth')", "$tlang.getString('java.byyear')", "$tlang.getString('java.listeve')"])
Localizing JSF Templates <f:loadBundle basename="org.sakaiproject.tool.annc.bundle.Messages" var="msgs"/> <f:view> <sakai:view_container title="#{msgs.annc_list_title}"> <h:form> <sakai:tool_bar> <sakai:tool_bar_item action="#{AnnouncementTool.processActionListNew}" value="#{msgs.annc_list_new}" />
Localizing Java Code (before) private static final String STATE_SELECTED_VIEW = "state_selected_view"; private static final String VIEW_BY_DAY = "Calendar by day"; private static final String VIEW_BY_WEEK = "Calendar by week"; private static final String VIEW_BY_MONTH = "Calendar by month"; private static final String VIEW_BY_YEAR = "Calendar by year"; … context.put("selectedView", VIEW_BY_DAY);
Localizing Java Code (after) private static ResourceBundle rb = ResourceBundle.getBundle("calendar") private static final String STATE_SELECTED_VIEW = "state_selected_view"; private static final String VIEW_BY_DAY = rb.getString("java.byday"); private static final String VIEW_BY_WEEK = rb.getString("java.byweek"); private static final String VIEW_BY_MONTH = rb.getString("java.bymonth"); private static final String VIEW_BY_YEAR = rb.getString("java.byyear"); … context.put("selectedView", VIEW_BY_DAY);
Localization Status • Thanks to the developers at University of Lleida, almost every English phrase has been localized into Resource Bundles (almost 4000 separate phrases) • Translation mostly completed in Japanese, Korean and Chinese • Interest has been expressed in Slovokian, Portugese, Catalonia, Spanish, Armenian, Hebrew, …
Korean Chinese Japanese Asian Translations for NEESgrid portal
How to Translate… in 5 easy steps • Ingest properties files into MS Excel Spreadsheet • Translate English Text in spreadsheet • Export into Unicode UTF-16 representation • Convert from UTF-16 into UTF-8 • Ascii-encode UTF-8 representation and save as property file for target language locale (see “I18N and L10N” worksite at http://collab.sakaiproject.org/portal for tips and conversion utilities)
Dynamic Language Detection • What about portals that need to support multiple language locales? • Requirements: • Minimum change to existing code and tools • Use existing ResourceBundle properties files • Simple for users to use • Tatsuki Sugiura at Nagoya University has developed an elegant solution
New ResourceLoader class • New ResourceLoader class replaces java.util.ResourceBundle • ResourceLoader works as a ManagedBean for Java Server Faces (JSF) • ResourceLoader works as a wrapper for ResourceBundle for java and Velocity templates • Language Locale retrieved from HTTP request
Users define language preference in browser (IE, Netscape, Safari, Firefox, …)
Enabling Sakai Internationalization • Page Layout and design • Sentence construction (subject/verb/object) • Timezone differences • Date & Time construction • Definition of a Week • Numbers & Currency • Language dependent sorting • Other culturally dependent data
Page Layouts (skins) • Page layouts can differ for application specific reasons or cultural reasons (e.g. right-to-left languages) • Layout is completely configurable using CSS (Cascading Style Sheets) • Different skins can affect: • Color & Fonts • Icons & Background Images • Layout & Format • Navigation
Skin Directory Structure /library/skin/ tool_base.css /default/ /tool.css /portal.css banner_inst.gif info.gif title.1.gif topleft-tab.gif check.gif linkoff.gif title22.gif topleft-tab_hov.gif headback.gif linkover.gif titleback.gif topright-p-title.gif headmid.gif linksel.gif titleleft.gif warn.gif headright.gif logo_inst.gif titleright.gif help.gif reload.gif topleft-curtab.gif help_h.gif reload_h.gif topleft-p-title.gif /images/ Define your skin here /new-skin/
Right-justified Skins(thanks to Gonzalo Silverio for screenshots)
What’s not done yet • Problem: Subject/Verb/Object, Subject/Object/Verb, Verb,Subject,Object constructions • Solution: Need to rewrite to use MessageFormat for these compositions • Problem: Timezone differences • Solution: Add timezone option to user preferences and modify affected tools (e.g. Calendar, Chat) • Problem: Date & Time construction • Solution: Java provides date/time constructions specific to language locale -- code needs to be audited for consistent usage
What’s not done yet (continued) • Problem: Definition of a week • Solution: Configuration option needs to be built into Schedule tool • Numbers & Currency • Solution: Java provides number/currency constructions specific to regional locales -- code needs to be audited for consistent usage • Language independent sorting • Solution: Java provides correct unicode string comparisons -- code needs to be audited for consistent usage