Nicolas Petton | 11 May 16:43

Aida-Localization

Hi all,

I started a to work on a localization support for Aida.
It's available at: http://mc.bioskop.fr/AidaLocalization

It's quite simple for now: AIDASite has a #preferedLanguage accessor
which return a symbol (by default #en), and has a translator, an
instance of AIDATranslator.

A translator knows how to translate a sentence:

(AIDASite named: 'aidademo') translator addTranslation:
('Hello'->'Bonjour') language: #fr

then 

(AIDASite named: 'aidademo') translator translate: 'Hello' to: #fr
>>>'Bonjour'

in views we can translate a sentence with:

self translate: aString

for example:

#viewMain
    | e |
    e := WebElement new.
    self title: (self translate: 'Hello').
    e addTextH1: self title.
    self pageFrameWith: e title: self title

if the corresponding translation is not found, the string is just
returned.

Finally, we can change the language of a site with: 

(AIDASite named: 'aidademo') preferedLanguage: #fr

And all translations are stored in a dictionary in a class variable, so
each translator (one per site) knows all available translations.

It's already working, but could certainly be improved.

Cheers!

Nico
-- 
Nicolas Petton
http://nico.bioskop.fr
            ___
          ooooooo
         OOOOOOOOO
        |Smalltalk|
         OOOOOOOOO
          ooooooo
           \   /
            [|]
--------------------------------
Ma clé PGP est disponible ici :
http://nico.bioskop.fr/pgp-key.html
Hi all,

I started a to work on a localization support for Aida.
It's available at: http://mc.bioskop.fr/AidaLocalization

It's quite simple for now: AIDASite has a #preferedLanguage accessor
which return a symbol (by default #en), and has a translator, an
instance of AIDATranslator.

A translator knows how to translate a sentence:

(AIDASite named: 'aidademo') translator addTranslation:
('Hello'->'Bonjour') language: #fr

then 

(AIDASite named: 'aidademo') translator translate: 'Hello' to: #fr
>>>'Bonjour'

in views we can translate a sentence with:

self translate: aString

for example:

#viewMain
    | e |
    e := WebElement new.
    self title: (self translate: 'Hello').
    e addTextH1: self title.
    self pageFrameWith: e title: self title

if the corresponding translation is not found, the string is just
returned.

Finally, we can change the language of a site with: 

(AIDASite named: 'aidademo') preferedLanguage: #fr

And all translations are stored in a dictionary in a class variable, so
each translator (one per site) knows all available translations.

It's already working, but could certainly be improved.

Cheers!

Nico
--

-- 
Nicolas Petton
http://nico.bioskop.fr
            ___
          ooooooo
         OOOOOOOOO
        |Smalltalk|
         OOOOOOOOO
          ooooooo
           \   /
            [|]
--------------------------------
Ma clé PGP est disponible ici :
http://nico.bioskop.fr/pgp-key.html

Gmane