Localisation of Seaside apps

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Localisation of Seaside apps

Martin J. Laubach-2
  I just had to submit an offer for a web application with localisation.
After thinking a bit about it, I must admit that all my solutions so far
are rather unwieldly.

  Having separate #renderContentOn for each language smells pretty bad.
Code duplication and all that.

  The problem is not so much with small embedded descriptive strings
on a page (like "html text: 'Username'"), those I can just replace
with "html text: (TextCatalog at: #username)" or such.

  The real problem comes with larger texts with embedded links. Here,
not only the text changes, but also the link text and the link position.
For example: "Click <a>here</a> to register" gives "Zur Registrierung
klicken sie bitte <a>hier</a>".

  One could solve that by just dividing up the text as in

        html text: (TextCatalog at: #preLinkText).
        html anchorWithAction: [] text: (TextCatalog at: #linkText).
        html text: (TextCatalot at: #postLinkText).

  but this gets out of hand pretty fast. Not to mention that one
may have multiple links that get switched in position relative to each
other.

  That's one of the moments I think some template based preprocessor
would be nice. Or wouldn't it? I'm thinking of something like a way
to turn a string 'Click [here=self call: doRegistration] to register'
into a #renderContentOn-like method.

  Regards,

        mjl
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Localisation of Seaside apps

Brent Pinkney
Hi,

>   I just had to submit an offer for a web application with localisation.
> After thinking a bit about it, I must admit that all my solutions so far
> are rather unwieldly.

Our web application is fully localised:

We modifed to signal a notification to return the preferred instance
of NaturalLanguageTranslater:

        String >> translated
                "answer the receiver translated to the default language"

                ^ CurrentTranslator signal translate: self

We implemented CurrentTranslator as a subclass of Notification with:

        CurrentTranslator  >> defaultAction
                "Answer the current system-wide NaturalLanguageTranslator."

                ^ NaturalLanguageTranslator current


So far, the string translation functions as it always has.

The entry point for any Seaside application is either WAMain >> start: for new requests
or WASession >> peformRequest for requests with a valid session key. We overrode our
subclass's implementation to catch the CurrentTranslator signal and answer the appropriate
translator as stored in the WASession, viz:

        BpAuthMain >> start:

                [ super start: aRequest ]
                        on: CurrentTranslator
                        do: [ :e | e resume: self session translator ]

and similarly for #performRequest:


We then subclasses WASession to include an instance variable for the current LocalID.
This can return the appropriate translator. We use Basic authentication to identify the user and read
the locale ID from our database.


Our solution allows each Seaside session to have its own translator so different users can have the
results rendered in different languages.


Note: We were not sure whether to use a Notification to answer the preferred translator or a DynamicBinding.
So far we have not detected any performance problems with this approach.


Contact me directly if you need more help or sample code. PS. We would really like this functionality to
migrate its way into the offical Seaside distribution and would be willing to modify our implementation accordingly.

Regards

Brent











_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Localisation of Seaside apps

Lukas Renggli
> Note: We were not sure whether to use a Notification to answer the preferred translator or a DynamicBinding.
> So far we have not detected any performance problems with this approach.

We use the same approach with notifications in two of our
applications. We wrote our own NaturalLanguageTranslator, since at
that time there was nothing of that kind in Squeak.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside