Changes for page Development-Localization and Internationalization
Last modified by Pascal Robert on 2015/05/04 04:24
From version 28.1
edited by Ramsey Gurley
on 2010/12/03 13:39
on 2010/12/03 13:39
Change comment:
I'm getting too much credit at this point I think. Removed my name from the heading :)
To version 30.1
edited by David Holt
on 2009/11/18 10:08
on 2009/11/18 10:08
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. ramsey1 +XWiki.dholt - Content
-
... ... @@ -1,6 +1,6 @@ 1 1 == Unicode == 2 2 3 -See also: [[UTF-8 Encoding Tips >>UTF-8 Encoding Tips]]3 +See also: [[UTF-8 Encoding Tips]] 4 4 5 5 To Enable Unicode for your WO app, add the following to your application constructor: 6 6 ... ... @@ -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 === 73 +=== 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 ... ... @@ -114,7 +114,7 @@ 114 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: 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: 118 118 119 119 Project->Resources->English.lproj->Localizable.strings 120 120 Project->Resources->Japanese.lproj->Localizable.strings ... ... @@ -122,16 +122,16 @@ 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 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 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. 129 +You would right-click->Refactor->Move it to 134 134 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. 134 + 135 135 Your layout would end up something like this: 136 136 137 137 [[image:ERXLocalizerEclipseLayout.png]] ... ... @@ -138,14 +138,10 @@ 138 138 139 139 ===== Localized EOAttributes ===== 140 140 141 -In Wonder, it is also possible to localize attributes. Let's say wehaveanentity//Blog// withan attribute//content// thatwe want tolocalize. This will berealized by not creating a column //content//in the database but a column for each specified language we wanti.e. //content//en//, //content//fr//, ...141 +In Wonder, it is also possible to localize attributes. There are two requisites: 142 142 143 - To tell EOFthat we want a specific attributelocalizedyou have to adda keyERXLanguages toitsuser info.143 +First add ERXLanguages to your Properties file: 144 144 145 -[[image:ERXLocalizerUserInfo_correct.png||border="1"]] 146 - 147 -In this example we set the type to //Array// and add an item for each needed language setting its value to the language code. This must be done for each attribute in our model we want to localize. If you have many localized attributes that have the very same list of languages and you will likely be changing that list in the future you can define your language list either for a whole model or for all models instead. The first way to specify a per model language list is to put an ERXLanguages key into the user info of the model. For a global setting put that key into your property file: 148 - 149 149 {{noformat}} 150 150 151 151 ERXLanguages = (en,jp,fr_ca) ... ... @@ -152,12 +152,9 @@ 152 152 153 153 {{/noformat}} 154 154 155 - Allattributesthat shoulduse thoseglobalsettings must have akey//ERXLanguages//intheiruserinfowith a type **different** to //Array//.Its value can be anythingas onlythepresence of the keyis ofmportance.The order thathe languages are applied to an attributeis:151 +Then, for the attribute you'd like to localize, add the ERXLanguages key to the UserInfo for that specific attribute: 156 156 157 -* attribute user info with an array for ERXLanguages 158 -* if type of found user info is not an array then get array from key ERXLanguages from user info of the model 159 -* if user info of the model has no key ERXLanguages look for a property ERXLanguages in your property files 160 -* if no property ERXLanguages is found ignore localization 153 +[[image:ERXLocalizerUserInfo.png]] 161 161 162 162 ===== Direct Actions ===== 163 163 ... ... @@ -180,8 +180,6 @@ 180 180 181 181 That should give the user their browser's default language setting instead of your server's default language setting until a session is created. 182 182 183 -[[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. 184 - 185 185 ===== Database setup ===== 186 186 187 187 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: ... ... @@ -189,7 +189,3 @@ 189 189 jdbc:mysql:~/~/localhost/mydatabase?capitalizeTypenames=true&zeroDateTimeBehavior=convertToNull&characterEncoding=UTF-8 190 190 191 191 The database itself is set to default to "UTF8" encoding. (No hyphen in UTF8 for MySQL) You can set that in the "Options" pane of MySQL Administrator.app under the "Advanced" popup menu item in the "Def. char set" field. Of course, you'll need to use the correct database types too, meaning don't use a blob for text storage. Use varchar and longtext (varcharLarge is the name of the Wonder prototype) instead. 192 - 193 -===== Localization presentation from WOWODC West 2009 ===== 194 - 195 -Guido Neitzer did a localization presentation at WOWODC West 2009 that give a good overview of how to localize your apps. The presentation is available [[here>>http://www.wocommunity.org/podcasts/wowodc/west09/WOWODCW09-Localization.mov]].