NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: tglomb on March 20, 2014, 07:56:27 AM

Title: UI runtime translation
Post by: tglomb on March 20, 2014, 07:56:27 AM
Does anybody knows a way of a translation of all text at runtime ? In my project I must let the enduser select at runtime a certain language, at least German, English, Italian, .. with a single click on a button. Is it possible todo via mapping tables for any elements in the UI ?
Any ideas apreciated !
TIA, Thomas
Title: Re: UI runtime translation
Post by: Alberto on March 20, 2014, 08:44:33 AM
Yes, Nt has a Translate Method that is used almost in every part of the Nt.

Then you have to go to the Translate method in the WebHandler, before the parencall and add some code like the following:


    Returnvalue = p_string

       TRA:TranslateFrom = p_string
       get(Translate,TRA:XFROM)
       if error() !traslate string not found then I add a record to the transaltion file (I use a TPS file)
          if loc:Add=1  !getini('translation','add',1,'.\TRANSLAT.INI')=1
             clear(tra:record)
             TRA:TranslateFrom = p_string
             !Trace('Adding Translate From: '&TRA:TranslateFrom)
             TRA:ProcedureName = GlobalErrors.GetProcedureName()
             Access:Translate.TryInsert()
          end
          ReturnValue = ''
       else
          if loc:Repair=1 !getini('translation','repair',0,'.\TRANSLAT.INI')=1
             TRA:TranslateFrom = p_string
             TRA:ProcedureName = GlobalErrors.GetProcedureName()
             PUT(Translate)
          END
          ReturnValue = choose(p_web.gsv('LOGIN_lngCol')+1, TRA:TranslateTo_00, TRA:TranslateTo_01, TRA:TranslateTo_02, TRA:TranslateTo_03, TRA:TranslateTo_04, TRA:TranslateTo_05, TRA:TranslateTo_06, TRA:TranslateTo_07, TRA:TranslateTo_08, TRA:TranslateTo_09, TRA:TranslateTo_10, TRA:TranslateTo_11, TRA:TranslateTo_12, TRA:TranslateTo_13, TRA:TranslateTo_14, TRA:TranslateTo_15, TRA:TranslateTo_16, TRA:TranslateTo_17, TRA:TranslateTo_18, TRA:TranslateTo_19, TRA:TranslateTo_20)
          !p_web.AddLog('Translate: '&p_String&' '&p_web.gsv('LOGIN_lngCol')&' '&clip(ReturnValue))
       end

       if ReturnValue = ''
          ReturnValue = p_string
       end

    end

    ReturnValue = parent.Translate(ReturnValue,p_AllowHtml)
    Return clip(ReturnValue)

Title: Re: UI runtime translation
Post by: tglomb on March 20, 2014, 11:36:47 AM
Thanks Michaelis,
it works well, I was not aware of this procedure.. I not found a description of all the methods up to now (besides the class embeds)..
It is correct that the 00 to 20 representing the placeholders for your languages ?
Ciao Thomas
Title: Re: UI runtime translation
Post by: Alberto on March 20, 2014, 12:33:39 PM
Yes its correct, I save my langues in one table, many columns.
Regards
Title: Re: UI runtime translation
Post by: Bruce on March 20, 2014, 10:08:04 PM
Hi Thomas,

you may also be interested in AnyText, which now has support for NetTalk web apps "built-in". see
http://www.capesoft.com/docs/anytext/anytext.htm (http://www.capesoft.com/docs/anytext/anytext.htm)
and specifically
http://www.capesoft.com/docs/anytext/anytext.htm#web (http://www.capesoft.com/docs/anytext/anytext.htm#web)
for more.

cheers
Bruce