[Gambas-user] Applying translation to a running application
Benoit Minisini
gambas at ...1...
Wed Sep 24 13:28:27 CEST 2008
On mercredi 24 septembre 2008, Charlie Reinl wrote:
> Am Dienstag, den 23.09.2008, 22:54 +0200 schrieb Benoit Minisini:
> > 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.
>
> Yes I know that gambas uses gettext.
> But I don't like, that we have to recompile after changes made
> in *.po files.
>
The IDE does everything for you, you don't see that.
--
Benoit Minisini
More information about the User
mailing list