Panu, maybe you may want to cc seaside mailing list too ;)<br><br><div class="gmail_quote">On Fri, Sep 10, 2010 at 2:41 PM, Panu Suominen <span dir="ltr">&lt;<a href="mailto:panu.j.m.suominen@gmail.com">panu.j.m.suominen@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">2010/9/10 Stanislav Paskalev &lt;<a href="mailto:kshorg@gmail.com">kshorg@gmail.com</a>&gt;:<br>

<div class="im">&gt; Seaside had none the last time I asked. Please do so.<br>
<br>
</div>I am in a bit hurry, but I hope you can still make sense out of this.<br>
<br>
The whole seaside and translation thing is based on the fact that<br>
Seaside render: method is dispatched to objects renderOn: method where<br>
we can access session. On the other hand<br>
we can store language to session. If we implement object that is able<br>
to answer correctly to translate: -message with language as a<br>
parameter we have a simple translation framework.<br>
<br>
I created a simple translation framework which is able to return<br>
translation for certain key. Keys are looked from properly named<br>
subclass. Names are form of LanguagePackOfProgramX_fi,<br>
LanguagePackOfProgramX_en. Each containing translations for the given<br>
language. K3LanguagePack and tests should give better idea.<br>
<br>
Notice that examples below need language -method in session....<br>
<br>
Example to use with seaside:<br>
<br>
renderContentOn: html<br>
    html render: (LanguegPackOfMyProgram translationFor: #greetingMessge)<br>
<br>
<br>
Example with magritte:<br>
descriptionEmail<br>
       ^MAStringDescription new<br>
                accessor: #email;<br>
                label: (K3CoreLanguagePack translationFor: #email);<br>
                addCondition: [:value | value includes: $@] labelled:<br>
(LanguegPackOfMyProgram translationFor: #emailNotValid);<br>
                beRequired; requiredErrorMessage:<br>
(LanguegPackOfMyProgram translationFor: #emailIsRequired);<br>
                priority: 10;<br>
                yourself.<br>
<br>
<br>
The magritte part was builded on top of 2.0.5 magritte-seaside.<br>
<br>
This code enabled me to build seaside application demo that could<br>
change its user interface on the fly. Meaning that anything else stays<br>
as it is, only the language changes.<br>
But I don&#39;t know how useful this is for other people.<br>
<br>
Currently the major flaw is that there is no way to set the arguments<br>
for the translation (&#39;Hello user, your name is {1}&#39;). It is not a big<br>
addition but haven&#39;t needed it in this proof of concept. However it<br>
should not be very hard to implement.<br>
<br>
Other thing that should be discussed is the way translations are<br>
stored. I chose to use symbols that points to methods and thus<br>
translations can be encapsulated in classes. However there seems to be<br>
NaturalLanguageTranslator and string translate already in existence<br>
and I am wondering should I change the implementation to use them<br>
instead.<br>
<br>
I am very open to suggestions.<br>
<br>
--<br>
<font color="#888888">Panu<br>
</font><br>_______________________________________________<br>
Pharo-users mailing list<br>
<a href="mailto:Pharo-users@lists.gforge.inria.fr">Pharo-users@lists.gforge.inria.fr</a><br>
<a href="http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users" target="_blank">http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users</a><br>
<br></blockquote></div><br>