From: Ankur G. S. <g35...@gm...> - 2005-05-11 17:00:23
|
Hi I have not been getting myself upto date on the latest version of webmacro, last I downloaded the api was in march of 2004. Now I have a task at hand where in I have to support languages like chinese, french and many more... How do i go about doing this? Anything special I have to do, some examples would be great. Also when I put text into the webmacro file from java, can I put any char(unicode for other languages) since I will picking these translated words from an XML file. Thanks Ankur |
From: Ankur G. S. <g35...@gm...> - 2005-05-11 17:01:59
|
Hi I have not been getting myself upto date on the latest version of webmacro, last I downloaded the api was in march of 2004. Now I have a task at hand where in I have to support languages like chinese, french and many more... How do i go about doing this? Anything special I have to do, some examples would be great. Also when I put text into the webmacro file from java, can I put any char(unicode for other languages) since I will picking these translated words from an XML file. Thanks Ankur |
From: <Web...@St...> - 2005-05-11 17:12:28
|
On Wed, 11 May 2005, Ankur G35 Saxena wrote: | Hi I have not been getting myself upto date on the latest version of | webmacro, last I downloaded the api was in march of 2004. Now I have a | task at hand where in I have to support languages like chinese, french | and many more... | | How do i go about doing this? Anything special I have to do, some | examples would be great. Also when I put text into the webmacro file | from java, can I put any char(unicode for other languages) since I | will picking these translated words from an XML file. There is an option in the WebMacro.properties file which states which encoding the input-files are in. The default (which is in WebMacro.default(s?), inside the jar) is UTF-8, as far as I remember. I think there is an output-thingy there too, which is the default encodin= g for the WMServlet and such. If you make your FastWriters yourself, you ca= n state the encoding when creating it. --=20 Endre St=F8lsvik - Endre@CoreTrek.[no|com] Work[+47 23100271] Mobile[+47 93054050] Fax[+47 23100299] |
From: Marc P. <ma...@an...> - 2005-05-11 17:44:38
|
Ankur G35 Saxena wrote: > Hi I have not been getting myself upto date on the latest version of > webmacro, last I downloaded the api was in march of 2004. Now I have a > task at hand where in I have to support languages like chinese, french > and many more... > > How do i go about doing this? Anything special I have to do, some > examples would be great. Also when I put text into the webmacro file > from java, can I put any char(unicode for other languages) since I > will picking these translated words from an XML file. The usual approach in JSP-land seems to be creating a ResourceBundle instance per session (assuming the language can be set by the client) and accessing that in the page for all UI strings... i.e. for "hello world": <html> <body> <b>$UIResourceBundle.HELLOWORLD</b> </body> </html> ...I'm rust on ResourceBundle so it might not support get(Object). Anyway the upshot of this is that you just need your servlet (or WM template I suppose) to get the language from the HTTP headers if possible, and then load the correct strings into a Map or similar, and put that in the session. Then in every page, in a common included header you can do: #set $UIStrings = $Session.XXXXX Where XXXX is where you get the stored Map from the session. You could of course do this by creating Maps in a common WM template (using #bean) containing all your translations so you don't have to mess with other files / ResourceBundle loading schemes (never been a fan of that mechanism). Then you could put those into maps by ISO language code... preferably trying to avoid it being done for every request (#macro / include as macro?) $stringsByCountryCode.put( "en", $stringsEN); $stringsByCountryCode.put( "fr", $stringsFR); $stringsByCountryCode.put( "de", $stringsDE); ...and then in every page processing you get the strings you need by: #set $UIStrings = $stringsByCountryCode.get($Session.XXXXX) ...and remember to check for null... Cheers -- Marc Palmer wj...@wa... Wangjammers - Java, J2ME and Web Consultants ~ http://www.wangjammers.org/ |
From: Graeme J S. <web...@gj...> - 2005-05-12 15:07:39
|
On Wed, 11 May 2005, Marc Palmer wrote: > Ankur G35 Saxena wrote: <snip/> >> How do i go about doing this? Anything special I have to do, some >> examples would be great. Also when I put text into the webmacro file >> from java, can I put any char(unicode for other languages) since I >> will picking these translated words from an XML file. This might help http://www.w3.org/TR/REC-html40/struct/dirlang.html > The usual approach in JSP-land seems to be creating a ResourceBundle instance > per session (assuming the language can be set by the client) and accessing > that in the page for all UI strings... <snip/> Thats how I did it. The translator was given a XML file which was easier for them to handle and with some XSLT it was converted to properties file for each locale. The language bundles were then loaded into the application context and passed to the user using their (selected) locale. -- Graeme - |