i18n tools

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

i18n tools

Panu Suominen-3
I am researching wether out team could start using Pharo. I have tried to locate
some tools to do user interface translations but I did not find
anything in time so I had
to develop some rudimentary key-based translation tools my self. I would like
to know is this lack of translation tools reality and if others are having same
kind of problems?

--
Panu

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Stéphane Ducasse
hilaire

can you provide some pointers because you did a lot of translations.

Stef

On Sep 9, 2010, at 9:12 PM, Panu Suominen wrote:

> I am researching wether out team could start using Pharo. I have tried to locate
> some tools to do user interface translations but I did not find
> anything in time so I had
> to develop some rudimentary key-based translation tools my self. I would like
> to know is this lack of translation tools reality and if others are having same
> kind of problems?
>
> --
> Panu
>
> _______________________________________________
> Pharo-users mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Panu Suominen-3
To stimulate little more.. I have done rudimentary translation support
for magritte and seaside.
Should I publish them or are there already working options?

--
Panu

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

solar_sea
Seaside had none the last time I asked. Please do so.

Stanislav Paskalev



On Fri, Sep 10, 2010 at 2:14 PM, Panu Suominen
<[hidden email]> wrote:

> To stimulate little more.. I have done rudimentary translation support
> for magritte and seaside.
> Should I publish them or are there already working options?
>
> --
> Panu
>
> _______________________________________________
> Pharo-users mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
>

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Panu Suominen-3
2010/9/10 Stanislav Paskalev <[hidden email]>:
> Seaside had none the last time I asked. Please do so.

I am in a bit hurry, but I hope you can still make sense out of this.

The whole seaside and translation thing is based on the fact that
Seaside render: method is dispatched to objects renderOn: method where
we can access session. On the other hand
we can store language to session. If we implement object that is able
to answer correctly to translate: -message with language as a
parameter we have a simple translation framework.

I created a simple translation framework which is able to return
translation for certain key. Keys are looked from properly named
subclass. Names are form of LanguagePackOfProgramX_fi,
LanguagePackOfProgramX_en. Each containing translations for the given
language. K3LanguagePack and tests should give better idea.

Notice that examples below need language -method in session....

Example to use with seaside:

renderContentOn: html
    html render: (LanguegPackOfMyProgram translationFor: #greetingMessge)


Example with magritte:
descriptionEmail
       ^MAStringDescription new
                accessor: #email;
                label: (K3CoreLanguagePack translationFor: #email);
                addCondition: [:value | value includes: $@] labelled:
(LanguegPackOfMyProgram translationFor: #emailNotValid);
                beRequired; requiredErrorMessage:
(LanguegPackOfMyProgram translationFor: #emailIsRequired);
                priority: 10;
                yourself.


The magritte part was builded on top of 2.0.5 magritte-seaside.

This code enabled me to build seaside application demo that could
change its user interface on the fly. Meaning that anything else stays
as it is, only the language changes.
But I don't know how useful this is for other people.

Currently the major flaw is that there is no way to set the arguments
for the translation ('Hello user, your name is {1}'). It is not a big
addition but haven't needed it in this proof of concept. However it
should not be very hard to implement.

Other thing that should be discussed is the way translations are
stored. I chose to use symbols that points to methods and thus
translations can be encapsulated in classes. However there seems to be
NaturalLanguageTranslator and string translate already in existence
and I am wondering should I change the implementation to use them
instead.

I am very open to suggestions.

--
Panu

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users

Korppi-Translation-PanuSuominen.4.1.cs (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Mariano Martinez Peck
Panu, maybe you may want to cc seaside mailing list too ;)

On Fri, Sep 10, 2010 at 2:41 PM, Panu Suominen <[hidden email]> wrote:
2010/9/10 Stanislav Paskalev <[hidden email]>:
> Seaside had none the last time I asked. Please do so.

I am in a bit hurry, but I hope you can still make sense out of this.

The whole seaside and translation thing is based on the fact that
Seaside render: method is dispatched to objects renderOn: method where
we can access session. On the other hand
we can store language to session. If we implement object that is able
to answer correctly to translate: -message with language as a
parameter we have a simple translation framework.

I created a simple translation framework which is able to return
translation for certain key. Keys are looked from properly named
subclass. Names are form of LanguagePackOfProgramX_fi,
LanguagePackOfProgramX_en. Each containing translations for the given
language. K3LanguagePack and tests should give better idea.

Notice that examples below need language -method in session....

Example to use with seaside:

renderContentOn: html
   html render: (LanguegPackOfMyProgram translationFor: #greetingMessge)


Example with magritte:
descriptionEmail
      ^MAStringDescription new
               accessor: #email;
               label: (K3CoreLanguagePack translationFor: #email);
               addCondition: [:value | value includes: $@] labelled:
(LanguegPackOfMyProgram translationFor: #emailNotValid);
               beRequired; requiredErrorMessage:
(LanguegPackOfMyProgram translationFor: #emailIsRequired);
               priority: 10;
               yourself.


The magritte part was builded on top of 2.0.5 magritte-seaside.

This code enabled me to build seaside application demo that could
change its user interface on the fly. Meaning that anything else stays
as it is, only the language changes.
But I don't know how useful this is for other people.

Currently the major flaw is that there is no way to set the arguments
for the translation ('Hello user, your name is {1}'). It is not a big
addition but haven't needed it in this proof of concept. However it
should not be very hard to implement.

Other thing that should be discussed is the way translations are
stored. I chose to use symbols that points to methods and thus
translations can be encapsulated in classes. However there seems to be
NaturalLanguageTranslator and string translate already in existence
and I am wondering should I change the implementation to use them
instead.

I am very open to suggestions.

--
Panu

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users



_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Panu Suominen-3
In reply to this post by Panu Suominen-3
2010/9/10 Hilaire Fernandes <[hidden email]>:
> I don't understand what you want to do.

I am researching a way to translate user interface in seaside application.
I have tried to look for code to take care of translations but haven't
found anything.

> Have you read the localisation chapter I wrote in the Pharo Collaboactive
> book?
I did not know that there is such a chapter there. Is there a link to
the book from pharo homepage?
However, the book gives me an error:
Seaside Walkback
Error: subscript is out of bounds: 8218

--
Panu

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Panu Suominen-3
In reply to this post by Panu Suominen-3
2010/9/10 Hilaire Fernandes <[hidden email]>:
> I don't understand what you want to do.
> Have you read the localisation chapter I wrote in the Pharo Collaboactive
> book?
Ok. Now I managed to see the localisation page. Thank you for the tip.
I try to integrate that to seaside.

--
Panu

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Miguel Cobá
In reply to this post by Panu Suominen-3
El jue, 09-09-2010 a las 22:12 +0300, Panu Suominen escribió:
> I am researching wether out team could start using Pharo. I have tried to locate
> some tools to do user interface translations but I did not find
> anything in time so I had
> to develop some rudimentary key-based translation tools my self. I would like
> to know is this lack of translation tools reality and if others are having same
> kind of problems?
>

There are effort to bring gettext infrastructure to Pharo and seaside.
Search the archives for details.

What I do in Seaside is to store create a base class for the default
languan, lets say, english:

MyLanguage

with class methods for each string that I want localized, f.e.

MyLanguage class>>greet
 ^ 'Hello User'

MyLanguage class>>numItems: num
  ^ '{1} items' format: {num}

This allows me to have parametrized messages.

Now for each language you want to support you create a subclass:

MyLanguage subclass: #MyLanguageESMX

and override each method you want to translate:

MyLanguageESMX class>>greet
 ^ 'Hola usuario'

MyLanguageESMX class>>numItems: num
 ^ '{1} elementos' format: {num}

If some method is missing in the subclass, it will take the value of the
parent class.

Now, to use it, store in each user session a inst var holding the
prefered _class_ for the language the user wants. And create an accessor
for this inst var:

WASession subclass: #MySession
        instanceVariableNames: 'user announcer language'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'MyPackage'

MySession>>lang
 ^ self user preferences language

Now when you want to emit a string do:

MyLogin>>renderContentOn: html
  html div
    id: 'login';
    with: [
      self session lang greet;
      self renderLoginOn: html ]

As the lang accessor returns the preferred lang class for the user, the
message greet is understood (they are class methods) and returns the
correct translated string for the given user.
To create a new translation, you  copy a existent subclass of MyLanguage
and rewrite the strings for the new language.

Of course this only takes care of the string translation, and does
nothing about currency and left-to-right issues in distinct languages.
For the  currency issue you can add a format message that emits the
correct representation of a number in the current locale but for the
direction of text, you'll need to look for other options, like the
gettext code I mentioned before.

Hope this helps.

Cheers
                       

--
Miguel Cobá
http://miguel.leugim.com.mx


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: i18n tools

Panu Suominen-3
In reply to this post by Panu Suominen-3
2010/9/10 Hilaire Fernandes <[hidden email]>:
> Check with Philip Marchall, he did modification to use gettext code with
> Seaside.

Ok. Thanks to all for the help. Seaside and gettext are apparently the magic
words that solves this problem. :)

http://forum.world.st/Seaside-Gettext-sneak-peak-td2164600.html

--
Panu

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users