Beta Release Comment language translator

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Beta Release Comment language translator

Post by Zebuddi123 »

Beta Single File Version (Project/multifile version after beta testing )

http://goo.gl/qBTjF UPDATE!!! sorry posted wrong rar file :oops: This is the correct one :D

MD5. 0551eaeb9697c18ab69b2a5877a81368

SetUp: Configure Tools.
Commandline -> this idetool
Arguments -> %FILE
working Directory -> Leave Blank
Event Trigger -> Your Choice
Shortcut -> Your Choice

Leave rest as is.

with chosen pb source in the current tab, activate tool, default browser will open at Google translate page.
paste into GTP
select language of choice (important please make sure, as auto detect language does not always get this right)
click google translate button
highlight translated strings
click copy (RMB)
a requester will pop up indicating clipboard text has changed ( with a small preview of the text) (just in case any other program people hackers) :shock: :lol: paste to the clipboard
click yes to continue if text look correct

as this is beta, a comprehesive debug log (file to desktop) will be created (this will be optional on final) and opened in notepad notepad++ which ever is default
the PBIde will open the newly translated file with the same name as the original filename. Appended with _TRANS_+date().pb
original file will not be altered, most files i have tried work straight of the bat, there are some exception mainly this being down to google translate (Not perfect) but stll a hell of a lot quicker than doing this manually
or learning multiple new languages

its beta ( like me ) :lol: so constructive criticism welcome :!:

so far the original comment only version has been downloaded 122 times so hopefully its been of use to some

if source code has not been saved then you will be prompted to save first. do so and activate again

Zebuddi. :D

small test courtesy of our french forum

Code: Select all

;{- Enumerations / DataSections
;{ Windows
Enumeration
  #window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
  #Panel_2
  #Text_infos
  #Text_27
  #Text_23
  #Text_21
  #String_port
  #Text_20
  #Text_19
  #Text_17
  #Text_16
  #Text_activite
  #Text_3
  #Button_4
  #Frame3D_5
  #Frame3D_7
  #Frame3D_8
  #IPAddress_1
  #CheckBox_tracert_1
  #IPAddress_2
  #CheckBox_tracert_2
  #String_serveur
  #String_user
  #String_pass
  #Text_26
  #string_destinataires
EndEnumeration
;}
;{ Fonts
Enumeration
  #Font_Panel_2
  #Font_Text_infos
  #Font_Text_27
  #Font_Text_23
  #Font_Text_21
  #Font_String_port
  #Font_Text_20
  #Font_Text_19
  #Font_Text_17
  #Font_Text_16
  #Font_Text_activite
  #Font_Text_3
  #Font_Button_4
  #Font_Frame3D_5
  #Font_Frame3D_7
  #Font_Frame3D_8
  #Font_IPAddress_1
  #Font_CheckBox_tracert_1
  #Font_IPAddress_2
  #Font_CheckBox_tracert_2
  #Font_String_pass
  #Font_Text_26
  #Font_string_destinataires
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_Window_0()
  If OpenWindow(#window_0, 550, 339, 449, 343, "Test réseau Ping / Tracert", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
    PanelGadget(#Panel_2, 20, 20, 410, 310)
      ; Tests
      AddGadgetItem(#Panel_2, -1, "Tests")
      TextGadget(#Text_infos, 15, 140, 370, 15, "", #PB_Text_Center)
      TextGadget(#Text_activite, 55, 235, 295, 20, "", #PB_Text_Center)
      TextGadget(#Text_3, 15, 10, 370, 125, "Ce programme est destiné à lancer une série de tests réseau vers les serveurs Portal. Les résultats sont normalement envoyés automatiquement par mail sans manipulation particulière. En cas d'échec de l'envoi, les résultats sont sauvegardés dans un fichier que nous récupèrerons.", #PB_Text_Border|#PB_Text_Center)
      ButtonGadget(#Button_4, 100, 175, 205, 25, "Lancer le test")
      Frame3DGadget(#Frame3D_5, 45, 215, 315, 45, "Activité")
      ; Paramètres
      AddGadgetItem(#Panel_2, -1, "Paramètres")
      TextGadget(#Text_27, 25, 235, 75, 20, "séparés par des ';'", #PB_Text_Center)
      TextGadget(#Text_23, 200, 182, 75, 20, "Mot de passe :", #PB_Text_Right)
      TextGadget(#Text_21, 60, 182, 40, 20, "User :", #PB_Text_Right)
      StringGadget(#String_port, 330, 150, 35, 20, "", #PB_String_Numeric)
      TextGadget(#Text_20, 35, 82, 85, 20, "Portal 1 :", #PB_Text_Right)
      TextGadget(#Text_19, 35, 47, 85, 20, "Portal 2 :", #PB_Text_Right)
      TextGadget(#Text_17, 280, 152, 45, 20, "Port :", #PB_Text_Right)
      TextGadget(#Text_16, 40, 152, 60, 20, "Serveur :", #PB_Text_Right)
      Frame3DGadget(#Frame3D_7, 20, 20, 365, 100, "Adresses")
      Frame3DGadget(#Frame3D_8, 20, 130, 365, 140, "SMTP")
      IPAddressGadget(#IPAddress_1, 130, 45, 140, 20)
      CheckBoxGadget(#CheckBox_tracert_1, 295, 45, 60, 20, "Tracert")
      IPAddressGadget(#IPAddress_2, 130, 80, 140, 20)
      CheckBoxGadget(#CheckBox_tracert_2, 295, 80, 55, 20, "Tracert")
      StringGadget(#String_serveur, 105, 150, 140, 20, "")
      StringGadget(#String_user, 105, 180, 90, 20, "")
      StringGadget(#String_pass, 280, 180, 85, 20, "")
      TextGadget(#Text_26, 30, 215, 70, 20, "Destinataires :")
      EditorGadget(#string_destinataires, 105, 210, 260, 50)
    CloseGadgetList()
    ; Gadget Resizing
    PureRESIZE_SetGadgetResize(#Panel_2, 1, 1, 1, 1)
    PureRESIZE_SetGadgetResize(#Text_infos, 1, 1, 1, 0)
    PureRESIZE_SetGadgetResize(#Text_27, 1, 0, 0, 1)
    PureRESIZE_SetGadgetResize(#Text_23, 0, 0, 1, 1)
    PureRESIZE_SetGadgetResize(#Text_21, 1, 0, 0, 1)
    PureRESIZE_SetGadgetResize(#String_port, 0, 0, 1, 1)
    PureRESIZE_SetGadgetResize(#Text_17, 0, 0, 1, 1)
    PureRESIZE_SetGadgetResize(#Text_16, 1, 0, 0, 1)
    PureRESIZE_SetGadgetResize(#Text_activite, 1, 0, 1, 1)
    PureRESIZE_SetGadgetResize(#Text_3, 1, 1, 1, 0)
    PureRESIZE_SetGadgetResize(#Button_4, 0, 0, 0, 1, #Panel_2)
    PureRESIZE_CenterGadget(#Button_4, 1, 0)
    PureRESIZE_SetGadgetResize(#Frame3D_5, 1, 0, 1, 1)
    PureRESIZE_SetGadgetResize(#Frame3D_7, 1, 1, 1, 0)
    PureRESIZE_SetGadgetResize(#Frame3D_8, 1, 0, 1, 1)
    PureRESIZE_SetGadgetResize(#CheckBox_tracert_1, 0, 1, 1, 0)
    PureRESIZE_SetGadgetResize(#CheckBox_tracert_2, 0, 1, 1, 0)
    PureRESIZE_SetGadgetResize(#String_serveur, 1, 0, 0, 1)
    PureRESIZE_SetGadgetResize(#String_user, 1, 0, 0, 1)
    PureRESIZE_SetGadgetResize(#String_pass, 0, 0, 1, 1)
    PureRESIZE_SetGadgetResize(#Text_26, 1, 0, 0, 1)
    PureRESIZE_SetGadgetResize(#string_destinataires, 1, 0, 1, 1)
    ; Gadget Fonts
    SetGadgetFont(#Panel_2, LoadFont(#Font_Panel_2, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_infos, LoadFont(#Font_Text_infos, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_27, LoadFont(#Font_Text_27, "Tahoma", 7, #PB_Font_HighQuality))
    SetGadgetFont(#Text_23, LoadFont(#Font_Text_23, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_21, LoadFont(#Font_Text_21, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#String_port, LoadFont(#Font_String_port, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_20, LoadFont(#Font_Text_20, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_19, LoadFont(#Font_Text_19, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_17, LoadFont(#Font_Text_17, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_16, LoadFont(#Font_Text_16, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_activite, LoadFont(#Font_Text_activite, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_3, LoadFont(#Font_Text_3, "Tahoma", 11, #PB_Font_HighQuality))
    SetGadgetFont(#Button_4, LoadFont(#Font_Button_4, "Tahoma", 9, #PB_Font_HighQuality))
    SetGadgetFont(#Frame3D_5, LoadFont(#Font_Frame3D_5, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Frame3D_7, LoadFont(#Font_Frame3D_7, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Frame3D_8, LoadFont(#Font_Frame3D_8, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#IPAddress_1, LoadFont(#Font_IPAddress_1, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#CheckBox_tracert_1, LoadFont(#Font_CheckBox_tracert_1, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#IPAddress_2, LoadFont(#Font_IPAddress_2, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#CheckBox_tracert_2, LoadFont(#Font_CheckBox_tracert_2, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#String_pass, LoadFont(#Font_String_pass, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#Text_26, LoadFont(#Font_Text_26, "Tahoma", 8, #PB_Font_HighQuality))
    SetGadgetFont(#string_destinataires, LoadFont(#Font_string_destinataires, "Tahoma", 8, #PB_Font_HighQuality))
    ; Gadget Colors
    PureCOLOR_SetGadgetColor(#Text_infos, $FF0000, #PureCOLOR_DontSetBackColor)
    PureCOLOR_SetGadgetColor(#String_port, #PureCOLOR_SystemColor, $B4FCF9)
    PureCOLOR_SetGadgetColor(#Text_activite, $8080FF, #PureCOLOR_DontSetBackColor)
    PureCOLOR_SetGadgetColor(#Text_3, #PureCOLOR_SystemColor, $B4FCF9)
    PureCOLOR_SetGadgetColor(#IPAddress_1, #PureCOLOR_SystemColor, $80FFFF)
    PureCOLOR_SetGadgetColor(#IPAddress_2, #PureCOLOR_SystemColor, $B4FCF9)
    PureCOLOR_SetGadgetColor(#String_serveur, #PureCOLOR_SystemColor, $B4FCF9)
    PureCOLOR_SetGadgetColor(#String_user, #PureCOLOR_SystemColor, $B4FCF9)
    PureCOLOR_SetGadgetColor(#String_pass, #PureCOLOR_SystemColor, $B4FCF9)
    PureCOLOR_SetGadgetColor(#string_destinataires, #PureCOLOR_SystemColor, $FFFFFF)
    ; Window Minimum Size
    PureRESIZE_SetWindowMinimumSize(#window_0, 449, 343)
  EndIf
EndProcedure




Procedure.s ping(ip$)
  SetGadgetText(#Text_activite,"Ping vers "+ip$)
  ping = RunProgram("ping",ip$,"",#PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
  sortie$ = ""
  If ping
    While ProgramRunning(ping)
      If AvailableProgramOutput(ping)
        sortie$ + ReadProgramString(ping) + #crlf$
      EndIf
    Wend
    ;MessageRequester("Stop",sortie$)
    CloseProgram(ping)
  EndIf
  SetGadgetText(#Text_activite," ")
  ProcedureReturn sortie$
EndProcedure

Procedure.s tracert(ip$)
  SetGadgetText(#Text_activite,"Traceroute vers "+ip$)
  tracert = RunProgram("tracert",ip$,"",#PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
  sortie$ = ""
  If tracert
    While ProgramRunning(tracert)
      If AvailableProgramOutput(tracert)
        sortie$ + ReadProgramString(tracert) + #crlf$
        ;OemToChar_(sortie$,sortie$)
        ;sortie$ + Chr(10)+Chr(13)
        
      EndIf
    Wend
    CloseProgram(tracert)
  EndIf
  SetGadgetText(#Text_activite," ")
  ProcedureReturn sortie$
EndProcedure



Procedure.b envoi_mail(message$)
  PureSMTP_SkipInitNetwork(0)
  SetGadgetText(#Text_activite,"Envoi des résultats par mail")
  MySMTPServer.s = GetGadgetText(#String_serveur)
  MySMTPPort.l = Val(GetGadgetText(#String_port))
  If PureSMTP_OpenSMTPConnection(MySMTPServer, MySMTPPort) = #PureSMTP_Ok
    Debug PureSMTP_GetLastServerMessage()
    MailTo.s = GetGadgetText(#string_destinataires)
    MailFrom.s = "test@test.com" ; mettre l'adresse de l'émetteur
    ExamineIPAddresses()
    ip = NextIPAddress()
    Subject.s = "Résultat de Ping / Tracert - Envoi depuis "+Hostname()+" ("+IPString(ip)+")"
    MsgBody.s = message$
    Attachments.s = ""
    Username.s = GetGadgetText(#String_user)
    Password.s = GetGadgetText(#String_pass)
    Status.l = PureSMTP_SendMail(MailTo, MailFrom, Subject, MsgBody, Attachments, Username, Password)
    If Status = #PureSMTP_Ok
      sent = #true
    Else
      sent = #False
    EndIf
    PureSMTP_CloseSMTPConnection()
  Else
    sent = #False
  EndIf 
  SetGadgetText(#Text_activite," ")
  ProcedureReturn sent
EndProcedure

Procedure save_fichier(res$)
  fic$ = GetTemporaryDirectory()+"test_reseau.txt"
  If CreateFile(0,fic$)
    WriteStringN(0,res$)
    CloseFile(0)
    
  EndIf
EndProcedure

Procedure lancer_test()
  result$ = ping(GetGadgetText(#IPAddress_1))
  
  If GetGadgetState(#CheckBox_tracert_1) = #pb_checkbox_checked
    result$ + tracert(GetGadgetText(#IPAddress_1))
  EndIf
  
  result$+#crlf$+#crlf$+ping(GetGadgetText(#IPAddress_2))+#crlf$+#crlf$
  
  If GetGadgetState(#CheckBox_tracert_2) = #pb_checkbox_checked
    result$ + tracert(GetGadgetText(#IPAddress_2))
  EndIf
  
  
  
  
  OemToChar_(result$,result$)
  save_fichier(result$)
  ;MessageRequester("info",result$)
  If envoi_mail(result$)
    MessageRequester("Information","Le résultat du test a correctement été envoyé.")
  Else
    r = MessageRequester("Erreur","Un problème est survenu dans l'envoi du fichier."+Chr(10)+"Voulez-vous ouvrir le fichier résultat du test ?",#PB_MessageRequester_YesNo)
    If r = #PB_MessageRequester_Yes
      RunProgram("notepad",GetTemporaryDirectory()+"test_reseau.txt","")
    EndIf
  EndIf
EndProcedure

Procedure initialisations()
  SetGadgetText(#String_serveur,"") ; mettre l'adresse du serveur de messagerie
  SetGadgetText(#String_port,"25")
  SetGadgetState(#IPAddress_1,MakeIPAddress(192,168,1,1)) ; adresse IP à tester
  SetGadgetState(#IPAddress_2,MakeIPAddress(192,168,1,2)) ; adresse IP à tester
  SetGadgetState(#CheckBox_tracert_2,1)
  SetGadgetText(#string_destinataires,"toto@toto.com;titi@titi.com") ; mettre les adresse mail des destinataires, séparées par des ";"
  SetGadgetText(#Text_activite,"En attente")
  InitNetwork()
  ExamineIPAddresses()
  ip = NextIPAddress()
  SetGadgetText(#Text_infos,Hostname()+" - "+IPString(ip))
EndProcedure


OpenWindow_Window_0()

initialisations()


;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
      ; ///////////////////
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = #Button_4
        lancer_test()

      EndIf
      ; ////////////////////////
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = #window_0
        CloseWindow(#window_0)
        Break
      EndIf
  EndSelect
ForEver
;
;}
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: Beta Release Comment language translator UPDATE

Post by Zebuddi123 »

Sorry peoples posted wrong rar file :oops: proper beta1 in first post

Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: Beta Release Comment language translator

Post by electrochrisso »

MD5. 0551eaeb9697c18ab69b2a5877a81368
does not match the zip or the exe from the download, just being picky. :wink:
I will try this out when I get time, I am sure it will come in handy. :)
PureBasic! Purely the best 8)
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: Beta Release Comment language translator

Post by Zebuddi123 »

Hi electrochrisso

MD5 0551EAEB9697C18AB69B2A5877A81368 is for the current link.

I had rared the test example (posted in the link ) that i had translated and compiled initially :oops:

I have download the current link and checked just in case and it is the correct MD5 for the CLC_BETA_2.rar file.

MD5 for CLC_BETA_2.exe is 17F599C35E074C1FFB2FB36D16900D7A

Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: Beta Release Comment language translator

Post by electrochrisso »

Zebuddi123 wrote:Hi electrochrisso

MD5 0551EAEB9697C18AB69B2A5877A81368 is for the current link.

I had rared the test example (posted in the link ) that i had translated and compiled initially :oops:

I have download the current link and checked just in case and it is the correct MD5 for the CLC_BETA_2.rar file.

MD5 for CLC_BETA_2.exe is 17F599C35E074C1FFB2FB36D16900D7A

Zebuddi. :D
I reply to let you know your MD5 for CLC_BETA_2.exe is correct. :)
PureBasic! Purely the best 8)
Post Reply