[Gambas-user] Applying translation to a running application

M0E Lnx m0e.lnx at ...626...
Wed Sep 24 02:47:34 CEST 2008


How might one apply this for a form that is already opened?
I'm using a host form with a panel to host other forms..
My other forms are translated once the language is selected, but how
would I translate the host form?



On Tue, Sep 23, 2008 at 3:54 PM, Benoit Minisini
<gambas at ...1...> wrote:
> On mardi 23 septembre 2008, Charlie Reinl wrote:
>> Am Dienstag, den 23.09.2008, 12:43 -0500 schrieb M0E Lnx:
>> > Can anyone think of a way to apply a translation to an application
>> > that's already running?
>> >
>> > An example would be a wizard that starts out in English, and at the
>> > first step offers the user to choose their language.
>> > After the user selects his/her language, the rest of the application
>> > get translated to the selected language.
>> >
>> > I'm not talking about creating the translations... I already know how
>> > to do that... This is assuming there is a translated version for the
>> > listed languages.
>> >
>> > Anybody?
>>
>> Salut,
>>
>> one way is, all text to show, is stored in a Databasetable, only the
>> text which is used before the DB is connected,is burned in, and in
>> english.
>>
>> Here a simple form of that Table:
>>       lang            is GB,FR,DE or so
>>       token           is an unique token-key
>>       text            is the text in the language, fix by lang
>>
>> So in Form_Open or so you m ake :
>>
>> PUBLIC SUB Form_Open()
>> DIM rTest AS Result
>> rTest = meConn.Handle.Find("tblLang", "token = &1 and lang = &2",
>> "Label1",myLang)
>>         Label1.Text = rTest!Text
>> rTest = meConn.Handle.Find("tblLang", "token = &1 and lang = &2",
>> "Label2",myLang)
>>         Label2.Text = rTest!Text
>> ...... and so on .....
>> END
>>
>>  Do not forget all other texts use in messages, printouts and so on.
>
> My god... You have a Windows background, don't you? :-)
>
> Gambas has an integrated translation system based on the standard GNU tools.
> No need to reinvent the wheel there.
>
> Anyway, here is a little demo of how to change the application language at
> runtime:
>
> PUBLIC SUB Main()
>
>  DIM sLang AS String
>
>  DO
>    PRINT "Enter language code (fr, es, en...): ";
>    LINE INPUT sLang
>    System.Language = sLang
>    PRINT ("Hello")
>  LOOP
>
> END
>
> Of course, you must translate the "Hello" string in the IDE to see it
> translated!
>
> Beware that strings are not translated "on the fly". If a form is opened, you
> must destroy it and recreate it to see the new translations. In other words,
> strings are translated when they are used.
>
> Regards,
>
> --
> Benoit Minisini
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list