It is currently Thu Jun 20, 2013 6:07 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: language data change example?
PostPosted: Wed Oct 12, 2011 6:05 pm 
Offline
User
User
User avatar

Joined: Sat Sep 12, 2009 3:06 pm
Posts: 51
Anyone here show a small amount of code to give an example of couple languages in a app and how to switch between those language data perhaps a procedure example?

_________________
Edward B. Howington
http://www.triplexcorp.com


Top
 Profile  
 
 Post subject: Re: language data change example?
PostPosted: Wed Oct 12, 2011 6:45 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Sep 21, 2011 9:11 am
Posts: 125
Location: France (Paris)
Code:
EnableExplicit

Enumeration
  #Mainform
  #Text1
  #Name
  #Update
  #Language
EndEnumeration

Global PreferenceLanguage.i

Procedure.s SetText(Local.s, International.s)
  Select PreferenceLanguage
     
    Case 1 ;Local
      ProcedureReturn local
   
    Case 2;International
      ProcedureReturn International
   
  EndSelect
EndProcedure


Procedure ChangeLanguage(Value.i)
  PreferenceLanguage=Value

  SetWindowTitle(#Mainform, SetText("Titre en français", "English Title"))
  SetGadgetText(#Text1, SetText("Nom","Name"))
  SetGadgetText(#Name, SetText("Entrez votre nom","Enter your name"))
  SetGadgetText(#Update, SetText("Mise à jour","Update"))
EndProcedure


OpenWindow(#Mainform, 0, 0, 500, 300, "", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
TextGadget(#Text1, 10, 20, 80, 20, "")
StringGadget(#Name, 90, 20, 100, 20, "")
ButtonGadget(#Update, 200, 20, 80, 20, "")

ButtonGadget(#Language, 470, 270, 30, 30, "Fr")
SetGadgetData(#Language, 2)

ChangeLanguage(2)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Language
          If GetGadgetData(#language)=1
            SetGadgetData(#language, 2)
            SetGadgetText(#Language, "Fr")
            ChangeLanguage(2)
           
          Else
           
            SetGadgetData(#language, 1)
            SetGadgetText(#Language, "En")
            ChangeLanguage(1)
          EndIf
         
        Case #Update
          MessageRequester(SetText("Mise à jour","Update"), Settext("Mise à jour effectuée","Update performed"))
         
      EndSelect
       
    Case #PB_Event_CloseWindow
      End
  EndSelect
 
ForEver

_________________
Noob Inside - (Windows XP, 7 & 8: Full Version PB 4.51 -> 5.00)


Top
 Profile  
 
 Post subject: Re: language data change example?
PostPosted: Wed Oct 12, 2011 6:59 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2269
Location: Italy
viewtopic.php?p=191073#p191073

Change "Read" with "Read.s" (the code is for a older PB version)

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: language data change example?
PostPosted: Wed Oct 12, 2011 8:56 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1071
Location: Germany
You can take TailBite as an example for this masterpiece of code :wink:
(the link that luis had posted)

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye