Changes for page Development-Localization and Internationalization
Last modified by Pascal Robert on 2015/05/04 04:24
From version 46.1
edited by Pascal Robert
on 2010/09/19 11:14
on 2010/09/19 11:14
Change comment:
There is no comment for this version
To version 45.1
edited by Ramsey Gurley
on 2008/07/25 16:40
on 2008/07/25 16:40
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -Development-Localization and Internationalization 1 +Web Applications-Development-Localization and Internationalization - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. probert1 +XWiki.ramsey - Content
-
... ... @@ -1,7 +1,5 @@ 1 1 == Unicode == 2 2 3 -See also: [[UTF-8 Encoding Tips>>UTF-8 Encoding Tips]] 4 - 5 5 To Enable Unicode for your WO app, add the following to your application constructor: 6 6 7 7 {{code}} ... ... @@ -70,7 +70,7 @@ 70 70 71 71 If you use localized strings in your UTF-8 application you may also check out Project Wonder's [[ERXLocalizer>>WOnder-ERXLocalizer]] class. 72 72 73 -=== Project Localization tips [[~~ramsey]] === 71 +=== Project Localization tips [[~~ramsey]] === 74 74 75 75 The following are some tips and suggestions for localizing a project in WOLips using Project Wonder. 76 76 ... ... @@ -95,63 +95,52 @@ 95 95 96 96 {{/noformat}} 97 97 98 -Note that if you need to customize the locale for a language, such as Canadian French, you can do so with this property: 99 - 100 -{{noformat}} 101 - 102 -er.extensions.ERXLocalizer.French_CA.locale = fr_ca 103 - 104 -{{/noformat}} 105 - 106 -The other changes are then in the er.extensions.ERXLocalizer.availableLanguages and ERXLanguages: 107 -In the above case after adding canadian french these would change in: 108 - 109 -{{noformat}} 110 - 111 -er.extensions.ERXLocalizer.availableLanguages=(English,Japanese,French_CA) 112 - 113 -{{/noformat}} 114 - 115 115 ===== Localized strings and components ===== 116 116 117 -For each language available, you will need a corresponding Localizable.strings file. This file should be located in Projects->Resources->"Lang".lproj directory. In these directories, you'll store localized resources such as Localizable.strings files and localized components. So, continuing with the above example, you should create two new Localizable.strings files in the following places in your project directory: 98 +For each language available, you will need a corresponding Localizable.strings file. This file should be located in Projects->Resources->"Lang".lproj directory. In these directories, you'll store localized resources such as Localizable.strings files and localized components. So, continuing with the above example, you should create two new Localizable.strings files in the following places in your project directory: 118 118 119 119 Project->Resources->English.lproj->Localizable.strings 120 120 Project->Resources->Japanese.lproj->Localizable.strings 121 -Project->Resources->French//CA.lproj->Localizable.strings// 122 122 123 123 As mentioned earlier, it's recommended that these be in UTF-16 format. You can do that by right clicking on the file in WOLips and selecting "Properties." In the resources panel, change from the project default encoding to UTF-16. 124 124 125 -If you have any components that need localizing, then you should relocate that component from your Project->Components folder into the appropriate Lang.lproj folder. Then make a copy of the component into the remaining lproj directories and you can begin the process of localizing the component. You do not need more than one copy of the associated API or java file. You only need duplicates of the WO. So, as an example, if you wanted to localize 105 +If you have any components that need localizing, then you should relocate that component from your Project->Components folder into the appropriate Lang.lproj folder. Then make a copy of the component into the remaining lproj directories and you can begin the process of localizing the component. You do not need more than one copy of the associated API or java file. You only need duplicates of the WO. So, as an example, if you wanted to localize 126 126 127 127 > Project->Components->Main WO 128 ->\\ 129 ->>You would right-click->Refactor->Move it to 130 130 131 -> Project->Resources->English.lproj->Main WO 132 ->\\ 133 ->>and then right-click->Copy it from English.lproj and right-click->Paste it into Japanese.lproj. At this point, when you open the component in WOLips, there will be a tab at the bottom of the component editor view that allows you to switch back and forth between different localized versions of that component. 109 +You would right-click->Refactor->Move it to 134 134 135 - Yourlayoutwouldend upsomethingke this:111 +> Project->Resources->English.lproj->Main WO 136 136 137 - [[image:ERXLocalizerEclipseLayout.png]]113 +and then right-click->Copy it from English.lproj and right-click->Paste it into Japanese.lproj. At this point, when you open the component in WOLips, there will be a tab at the bottom of the component editor view that allows you to switch back and forth between different localized versions of that component. 138 138 139 -===== Localized EOAttributes=====115 +===== Component HTML ===== 140 140 141 - InWonder,it is alsopossibletolocalizeattributes.There are two requisites:117 +This one is pretty easy to figure out... but as a reminder, here's what the start of my PageWrapper looks like: 142 142 143 - First add ERXLanguages to your Properties file:119 +{{code}} 144 144 145 -{{noformat}} 121 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 122 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 146 146 147 -ERXLanguages = (en,jp,fr_ca) 124 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang='<wo:localized value = "ls_lang" />' lang='<wo:localized value = "ls_lang" />'> 125 +<head> 126 + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 148 148 149 -{{/ noformat}}128 +{{/code}} 150 150 151 - Then,forthe attribute you'dlikeolocalize,addtheERXLanguageskey totheUserInfoforthat specificattribute:130 +and in the Localizable.strings file, I keep a language code for each language 152 152 153 - [[image:ERXLocalizerUserInfo_correct.png||border="1"]]132 +{{code}} 154 154 134 +{ 135 + "ls_lang" = "en"; 136 +} 137 + 138 +{{/code}} 139 + 140 +You'll also notice the "ls//" prefix. You'll definitely want to prefix with something unique so you can do a project-wide search for your keys without difficulty.// 141 + 155 155 ===== Direct Actions ===== 156 156 157 157 If you are defaulting to direct actions, you may not have a session. If you do not have a session, the server will return the default language specified in the Properties mentioned above. If you're using direct actions and you don't like that behavior, you can stick this in your direct action class: ... ... @@ -173,8 +173,6 @@ 173 173 174 174 That should give the user their browser's default language setting instead of your server's default language setting until a session is created. 175 175 176 -[[Development-Localization and Internationalization^LocalizerTest.zip]] is an example application demonstrating the sessionless use of the localizer with localized strings and localized components, storing the language state in a cookie. 177 - 178 178 ===== Database setup ===== 179 179 180 180 Outside of this, if you are using a database, you'll need to make sure that is encoded properly as well. I'm using MySQL, so I have in my EOModel: