[Seaside] Internationalization
Torsten Bergmann
astares at gmx.de
Fri Sep 17 13:41:37 CEST 2004
Hi,
I was trying to write a simple seaside input form for german addresses. To
get support for german character encoding for texts I patched the
HtmlCharacters collection like this:
| encodings |
encodings := (WAAbstractHtmlBuilder classPool associationAt:
#HtmlCharacters) value.
#($ä 'auml' $ö 'ouml' $ü 'uuml' $ß 'szlig'
$Ö 'Auml' $Ö 'Ouml' $Ü 'Uuml' $ 'euro'
) pairsDo: [:t2 :t3 | encodings at: t2 asInteger + 1 put: '&' , t3 , ';']
Everything went fine when I wrote a label like this:
html text: 'Würden Sie ihre Straße eingeben'.
(which means "would you please enter your street"). It was correctly encoded
and displayed on the HTML page. Then I added an input field and
a submit button.
I enter my adress which is "Hauptstraße" which is the german form
for "main street". This word also has an $ß (ASCII code 167) in it and
when the submit button is pushed in the browser it is sent back to Seaside
as a Unicode string with two characters. (Character values 195 and 159).
Since these were encoded again I get "æuuml;" in the input field, which
then looks like this: "Hauptstraæuuml;e" in the edit field. This is in IE
with Encoding as UTF-8. When I use Firefox I get the same result on the
server, but it displays the edit field value as "Hauptstra?üe".
Even when I use #updateRoot: to insert a meta tag with the correct charset
it's not working. Attached is a short example. Hope the mail tools will
not convert characters here.
Any ideas how to correctly internationalize seaside applications? Any
plans for that in the near future?
thx
Torsten
--
Supergünstige DSL-Tarife + WLAN-Router für 0,- EUR*
Jetzt zu GMX wechseln und sparen http://www.gmx.net/de/go/dsl
-------------- next part --------------
WAComponent subclass: #GermanEncodingTest
instanceVariableNames: 'street'
classVariableNames: ''
poolDictionaries: ''
category: 'GermanEncodingTest'!
!GermanEncodingTest methodsFor: 'accessing' stamp: 'tbn 9/17/2004 12:53'!
street
^street! !
!GermanEncodingTest methodsFor: 'accessing' stamp: 'tbn 9/17/2004 12:53'!
street: anObject
street := anObject! !
!GermanEncodingTest methodsFor: 'rendering' stamp: 'tbn 9/17/2004 13:00'!
renderContentOn: html
html form: [
html
text: 'Wrden Sie hier Ihre Stra§e eingeben:';
break;
textInputWithValue: self street callback: [:aString |aString inspect.self street: aString];
submitButton]
! !
!GermanEncodingTest methodsFor: 'rendering' stamp: 'tbn 9/17/2004 13:26'!
updateRoot: anHtmlRoot
super updateRoot: anHtmlRoot.
anHtmlRoot docType: anHtmlRoot docType,'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'.
anHtmlRoot title: 'Seaside Tests: '! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
GermanEncodingTest class
instanceVariableNames: ''!
!GermanEncodingTest class methodsFor: 'class initialization' stamp: 'tbn 9/17/2004 12:54'!
initialize
self patchGermanEncoding.
self registerAsApplication: 'germantest'! !
!GermanEncodingTest class methodsFor: 'class initialization' stamp: 'tbn 9/17/2004 12:53'!
patchGermanEncoding
"Since seaside does not provide german character encoding we have to add them the
HtmlCharacters map.
See ISO-8859-1
"
| encodings |
encodings := (WAAbstractHtmlBuilder classPool
associationAt: #HtmlCharacters) value.
#($ 'auml' $ 'ouml' $ 'uuml' $§ 'szlig'
$
'Auml' $
'Ouml' $ 'Uuml' $ 'euro'
)
pairsDo: [:t2 :t3 | encodings at: t2 asInteger + 1 put: '&' , t3 , ';']! !
GermanEncodingTest initialize!
More information about the Seaside
mailing list