Translator/Übersetzer

  • Hier meine Variante ;)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <IE.au3>
    $Url = "http://translate.google.de/translate_t#"

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("Rapidtranslator by funkey", 400,120)
    $Label = GUICtrlCreateLabel("Bitte zu übersetzenden Text eingeben!",10, 10, 380, 20)
    $Input = GUICtrlCreateInput("",10,30, 380,20)
    $Btn_de_en = GUICtrlCreateButton("Übersetzen DE -> EN", 10, 55, 170, 20)
    $Btn_en_de = GUICtrlCreateButton("Übersetzen EN -> DE", 220, 55, 170, 20)
    $warten = GUICtrlCreateLabel("Bitte warten",10, 80, 380, 20)
    GUICtrlSetState( -1, $GUI_HIDE)
    $result = GUICtrlCreateInput("",10, 80, 380, 20)
    GUICtrlSetState( -1, $GUI_HIDE)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Btn_de_en Then
    $transdirection = "de|en|"
    $Text = GUICtrlRead($Input)
    If $Text <> "" Then
    GUICtrlSetData($result, trans($transdirection))
    EndIf
    EndIf
    If $msg = $Btn_en_de Then
    $transdirection = "en|de|"
    $Text = GUICtrlRead($Input)
    If $Text <> "" Then
    GUICtrlSetData($result, trans($transdirection))
    EndIf
    EndIf
    Sleep(20)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func trans($langdirection)
    GUICtrlSetState($warten, $GUI_SHOW)
    GUICtrlSetState($result, $GUI_HIDE)
    $oIE = _IECreate($Url&$transdirection&$Text,0,0,1)
    $oform = _IEFormGetObjByName($oIE, 1)
    $otext = _IEFormElementGetObjByName($oform , "gtrans")
    Do
    $translation = _IEFormElementGetValue($otext)
    Until $translation <> ""
    _IEQuit($oIE)
    GUICtrlSetState($warten, $GUI_HIDE)
    GUICtrlSetState($result, $GUI_SHOW)
    Return $translation
    EndFunc

    [/autoit]
  • Hier meine Variante ;) xD

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <ComboConstants.au3>
    #include <String.au3>
    #include <IE.au3>
    #include <GuiComboBoxEx.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $temp_readtxt, $wort
    Dim $language[5]
    $language[0] = "de"
    $language[1] = "en"
    $language[2] = "sv"
    $language[3] = "fr"
    $language[4] = "it"
    Dim $iconending[5]
    $iconending[0] = 'germany.ico'
    $iconending[1] = 'france.ico'
    $iconending[2] = 'sweden.ico'
    $iconending[3] = 'italy.ico'
    $iconending[4] = 'uk.ico'
    Dim $downloadlinks[5]
    $downloadlinks[0] = 'http://www.iconarchive.com/download/icon/iconscity/flags/germany.ico'
    $downloadlinks[1] = 'http://www.iconarchive.com/download/icon/iconscity/flags/france.ico'
    $downloadlinks[2] = 'http://www.iconarchive.com/download/icon/iconscity/flags/sweden.ico'
    $downloadlinks[3] = 'http://www.iconarchive.com/download/icon/iconscity/flags/italy.ico'
    $downloadlinks[4] = 'http://www.iconarchive.com/download/icon/iconscity/flags/uk.ico'
    Dim $i = 0
    Dim $proz = 0
    Dim $translateurl = 'http://translate.google.de/translate_t?hl=de#'

    [/autoit] [autoit][/autoit] [autoit]

    $dlread = IniRead(@ScriptDir & "config.ini", "Dl-Icons", "?", "default")
    If $dlread = "default" Then
    DirCreate(@ScriptDir & "translater-icons")
    ProgressOn("Download", "Icons werden gedownloadet ...", "Icon[1/5]: 0 %", 10, 10)
    _Download()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $Form1_1 = GUICreate("Translater - Jautois", 482, 305, 193, 125)
    GUISetIcon(@ScriptDir & "translatergermany.ico")
    $input = GUICtrlCreateEdit("", 8, 8, 465, 129)
    $hCombo = _GUICtrlComboBoxEx_Create($Form1_1, "", 8, 272, 121, 200, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("in", 136, 275, 13, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $hCombo2 = _GUICtrlComboBoxEx_Create($Form1_1, "", 152, 272, 120, 200, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
    $translatebut = GUICtrlCreateButton("Übersetzen", 352, 271, 121, 24, 0)
    $output = GUICtrlCreateEdit("", 8, 144, 465, 113, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFF0000)
    $Copy = GUICtrlCreateButton("Copy", 280, 271, 64, 24, 0)

    [/autoit] [autoit][/autoit] [autoit]

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @ScriptDir & "translater-iconsgermany.ico")
    _GUIImageList_AddIcon($hImage, @ScriptDir & "translater-iconsuk.ico")
    _GUIImageList_AddIcon($hImage, @ScriptDir & "translater-iconssweden.ico")
    _GUIImageList_AddIcon($hImage, @ScriptDir & "translater-iconsfrance.ico")
    _GUIImageList_AddIcon($hImage, @ScriptDir & "translater-iconsitaly.ico")
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)
    _GUICtrlComboBoxEx_AddString($hCombo, "Deutsch", 0, 0)
    _GUICtrlComboBoxEx_AddString($hCombo, "Englisch", 1, 1)
    _GUICtrlComboBoxEx_AddString($hCombo, "Schwedisch", 2, 2)
    _GUICtrlComboBoxEx_AddString($hCombo, "Französich", 3, 3)
    _GUICtrlComboBoxEx_AddString($hCombo, "Italienisch", 4, 4)

    [/autoit] [autoit][/autoit] [autoit]

    $hImage2 = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage2, @ScriptDir & "translater-iconsgermany.ico")
    _GUIImageList_AddIcon($hImage2, @ScriptDir & "translater-iconsuk.ico")
    _GUIImageList_AddIcon($hImage2, @ScriptDir & "translater-iconssweden.ico")
    _GUIImageList_AddIcon($hImage2, @ScriptDir & "translater-iconsfrance.ico")
    _GUIImageList_AddIcon($hImage2, @ScriptDir & "translater-iconsitaly.ico")
    _GUICtrlComboBoxEx_SetImageList($hCombo2, $hImage2)
    _GUICtrlComboBoxEx_AddString($hCombo2, "Deutsch", 0, 0)
    _GUICtrlComboBoxEx_AddString($hCombo2, "Englisch", 1, 1)
    _GUICtrlComboBoxEx_AddString($hCombo2, "Schwedisch", 2, 2)
    _GUICtrlComboBoxEx_AddString($hCombo2, "Französich", 3, 3)
    _GUICtrlComboBoxEx_AddString($hCombo2, "Italienisch", 4, 4)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Copy
    $temp_readoutput = GUICtrlRead($output)
    ClipPut($temp_readoutput)
    Case $translatebut
    $temp_readtxt = GUICtrlRead($input)
    $firsttrans = _GUICtrlComboBoxEx_GetCurSel($hCombo)
    $secondtrans = _GUICtrlComboBoxEx_GetCurSel($hCombo2)
    If ($firsttrans = -1) Or ($secondtrans = -1) Then
    MsgBox(0, "Error", "Bitte Sprache auswählen!")
    ElseIf ($firsttrans <> $secondtrans) Then
    $url = 'http://translate.google.de/translate_t?hl=de#' & $language[$firsttrans] & "|" & $language[$secondtrans] & "|"
    GUICtrlSetData($output, _getTranslationByGoogle($temp_readtxt))
    EndIf
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _getTranslationByGoogle($wort)
    $oIE = _IECreate($url & $wort, 0, 0)
    $text = _IEBodyReadText($oIE)
    Do
    $text = _IEBodyReadText($oIE)
    Until StringInStr($text, "Wir danken") <> 0
    If $firsttrans = 0 Then
    $text2 = _StringBetween($text, $wort & " ", "Deutsch")
    Else
    If $firsttrans = 1 Then
    $text2 = _StringBetween($text, $wort & " ", "Englisch")
    Else
    If $firsttrans = 2 Then
    $text2 = _StringBetween($text, $wort & " ", "Schwedisch")
    Else
    If $firsttrans = 3 Then
    $text2 = _StringBetween($text, $wort & " ", "Französisch")
    Else
    If $firsttrans = 4 Then
    $text2 = _StringBetween($text, $wort & " ", "Italienisch")
    EndIf
    EndIf
    EndIf
    EndIf
    EndIf
    _IEQuit($oIE)
    Return $text2[0]
    EndFunc ;==>_getTranslationByGoogle

    [/autoit] [autoit][/autoit] [autoit]

    Func _Download()
    While $i < 6
    If $i = 5 Then
    IniWrite(@ScriptDir & "config.ini", "Dl-Icons", "?", "1")
    ProgressOff()
    ExitLoop
    EndIf
    InetGet($downloadlinks[$i], @ScriptDir & "translater-icons" & $iconending[$i], 0, 1)
    While @InetGetActive
    $fullfilezize = InetGetSize($downloadlinks[$i])
    $proz = @InetGetBytesRead / $fullfilezize * 100
    $stringforprogress = Round($proz, 1)
    ProgressSet($proz, "Icon [" & $i + 1 & "/5]: " & $stringforprogress & " %")
    WEnd
    $i = $i + 1
    WEnd
    EndFunc ;==>_Download

    [/autoit]