Results 1 to 7 of 7

Thread: Need Help With a Rudimentary Translator

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2016
    Posts
    2

    Need Help With a Rudimentary Translator

    Hello all, I need help with a Rudimentary Translator. My teacher hasn't particular been of any help with Visual Basic at all, so I've been self teaching myself(quite poorly) for sometime now. The program is to take data from a "Dictionary.txt" file with languages such as English, French, German and Spanish and I have to have it translate from English to the latter languages. I have tried researching on ways to do this but all I have found has left me with someone stating that you shouldn't use a query before a for loop. I was wondering how I should go about querying my structure I have set up and selecting the relative translation of the words and outputting them onto the relative textboxes I have.

    YES,OU,JA,SI
    TABLE,TABLE,TISCH,MESA
    THE,LA,DEM,LAS
    IS,EST,IST,ES
    YELLOW,JAUNE,GELB,AMARILLO
    FRIEND,AMI,FREUND,AMIGO
    SICK,MALADE,KRANK,ENFERMO
    MY,MON,MEIN,MI
    LARGE,GROS,GROSS,GRANDE
    NO,NON,NEIN,NO
    HAT,CHAPEAU,HUT,SOMBRERO
    PENCIL,CRAYON,BLEISTIFT,LAPIZ
    RED,ROUGE,ROT,ROJO
    ON,SUR,AUF,EN
    AUTO,AUTO,AUTO,AUTO
    OFTEN,SOUVENT,OFT,A MENUDO

    Here's how the text file looks

    Code:
    Public Class Form1
        Public Structure translator
            Dim english As String
            Dim french As String
            Dim german As String
            Dim spanish As String
        End Structure
    
        Dim trans() As translator
    
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim translator() As String = IO.File.ReadAllLines("Dictionary.txt")
            Dim x As Integer = translator.Count - 1
            ReDim trans(x)
            Dim temp As String
            Dim sep() As String
            For i As Integer = 0 To x
                temp = translator(i)
                sep = temp.Split(","c)
                trans(i).english = sep(0)
                trans(i).french = sep(1)
                trans(i).german = sep(2)
                trans(i).spanish = sep(3)
            Next
        End Sub
    
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim parseeng() As String = TextBox1.Text.ToUpper.Replace(".", "").Split(" "c)
            Dim frenchprase(parseeng.Count - 1) As String
            Dim gerprase(parseeng.Count - 1) As String
            Dim spaparse(parseeng.Count - 1) As String
    
            TextBox2.Clear()
            TextBox3.Clear()
            TextBox4.Clear()
    
            Dim count As Integer = parseeng.Count - 1
    
            Dim query = From t In trans
                        Where t.english.SingleOrDefault = parseeng()
                        Select t.french, t.german, t.spanish
    
        End Sub
    
    End Class
    Here's what I have so far. Hopefully my question is clear enough.

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: Need Help With a Rudimentary Translator

    1-You are doing this in a Visual Basic.Net version, not Vb6.
    2-Yes in French is Oui, no Ou..
    3-If you want an example in VB6, I'll gladly give you one (based upon your 'rudimentary dictionaries'). But if you want in in VB.NET (some version), please post this in the proper forum (or I can ask a Moderator to move it for you.)

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2016
    Posts
    2

    Re: Need Help With a Rudimentary Translator

    Oh , sorry, I didn't know. Could you please ask a moderator to move it for me, thank you very much!

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Need Help With a Rudimentary Translator

    For best results you should also state which version of VB.Net you are using and which frame work you are targeting

  5. #5
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    Re: Need Help With a Rudimentary Translator

    I would look at using a dictionary collection instead an array of structure.
    The english word would be the key and a new class would be the lookup item.

    Code:
    Dim Translator as new Dictionary(Of String, clsWords)
    ...
    Public Class clsWords
      Public Property french As String = ""
      Public Property german As String = ""
      Public Property spanish As String = ""
    
      Public Sub New(sFrench as String, sSpanish as String , sGerman as String)
        french = sFrench
        spanish = sSpanish
        german = sGerman
      End Sub
    End Class
    BTW I would make all the words case insensitive and add case in the final output.
    Burn the land and boil the sea
    You can't take the sky from me


    ~T

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Need Help With a Rudimentary Translator

    Thread moved to the VB.Net forum.

  7. #7
    Fanatic Member
    Join Date
    Apr 2015
    Location
    Finland
    Posts
    679

    Re: Need Help With a Rudimentary Translator

    Microsoft has useable dictionary libraries/files including glossary for ui elements etc. for several languages, so you don't have to be a linquistic - so don't try to make translation vocabularies by yourself - just consentrate the translator program logic.

    https://www.microsoft.com/Language/en-US/Default.aspx

    These are in industry standard tbx format.
    https://en.wikipedia.org/wiki/TermBase_eXchange

    Currently nearly 100 languages tbx's are downloadable.
    https://www.microsoft.com/Language/e...rminology.aspx

    In past, there were glossaries available in .csv format to MSDN subscribers (as download and distributed in DVD version as well), maybe these are still downloadable.

    fex. couple of lines from french Biztalk Server 2004 glossary.

    "Polling Unit of Measure",,"Unité de mesure de l'interrogation",,"TXT",,"WinNT","BizTalk Server 2004"
    "The value for polling interval is invalid. It must be an integer from 0 through 65535.",,"Fréquence d'interrogation non valide. Cette valeur doit être un entier compris entre 0 et 65535.",,"TXT",,"WinNT","BizTalk Server 2004"
    "Response Root Element Name",,"Nom de l'élément racine de la réponse",,"TXT",,"WinNT","BizTalk Server 2004"
    "Columns to update:",,"Colonnes à mettre à jour :",,"TXT",,"WinNT","BizTalk Server 2004"
    "The value for retry interval is invalid. It must be an integer from 0 through 99.",,"Intervalle avant nouvelle tentative non valide. Cette valeur doit être un entier compris entre 0 et 99.",,"TXT",,"WinNT","BizTalk Server 2004"
    "Import...",,"Importer...",,"TXT",,"WinNT","BizTalk Server 2004"
    Last edited by Tech99; Feb 1st, 2016 at 08:15 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width