Language convertor (1 Viewer)

velox

Retired
Joined
Mar 19, 2004
Messages
5,521
Location
Where the citi never sleeps.
Gender
Male
HSC
N/A
i want to make a basic program that converts phrases to a different languages. I want it to translate to 6 langauges and i have 6 phrases. I have a combo box for both, ie for language and for phrase. THen i have a text box for it to display the translated text. I have no idea how to code this, my attempts have only resulted in multiple errors. thanks for any help u can provide!
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
If you tell us what errors you have, we can help you with those.
 

Fosweb

I could be your Doctor...
Joined
Jun 20, 2003
Messages
594
Location
UNSW. Still.
Gender
Male
HSC
2003
Firstly this is very complicated.

Not only do you have to recognise multiple languages and have a database for each language, if you want it to be useful, you will need to think about grammar...

But if you still are interested:
Build up a database where each english word has its equivalent word in the other languages. Then whenever a phrase is entered, recognise all words, match with corrosponding word in database, slot into new phrase. Easy. But not grammatically correct.


I wouldnt use arrays for this, basically because you will need to keep the same database all the time. Ie: the corrosponding words dont change when you close the program, so it saves time to just use a db rather than write a table from code when you run each translation.

Its basically just some string manipulation and a couple of simple database searches. Dont need arrays.

Thats not to say you couldnt do it with arrays though.

To answer your question on arrays however. (In a VB setting because you see to do vb)

You need to initialise an array in a general declatations area.
eg. Dim MyArray(100) as String
This says the items in the array MyArray (with 100 locations) will be string type.

Then to fill, all you need is a counter which tells you where you are writing to, and then you say: (for this example, a for loop is used to fill 100 locations with the number of the counter)

For arrCount = 0 to 100 (eeerrrr is it 99? whatever figure that out yourself (i'm on a mac atm - no vb))
MyArray(arrCount) = Str(arrCount)
Next arrCount
 

velox

Retired
Joined
Mar 19, 2004
Messages
5,521
Location
Where the citi never sleeps.
Gender
Male
HSC
N/A
sorry i should have stated, it only needs to convert 6 phrases....i did a case statement for the phrase but i can only do one language, i dont know how to do different languages, here is my code so far


Private Sub cmdTranslate_Click()
'added in this button to keep it from doing before your ready.
'case must be in this form

Select Case cmblanguage.Text
Case "French": Select Case cmbgreeting.Text
Case "Good Afternoon": txtdisplay = "1"
Case "Good Evening": txtdisplay = "2"
Case "Good Morning": txtdisplay = "3"
Case "Hello, How are you?": txtdisplay = "4"
Case "What is up?!": txtdisplay = "5"
Case "What is your name?": txtdisplay = "6"
End Select

Select Case cmbgreeting.Text
Case "German": Select Case cmbgreeting.Text
Case "Good Afternoon": txtdisplay = "1"
Case "Good Evening": txtdisplay = "2"
Case "Good Morning": txtdisplay = "3"
Case "Hello, How are you?": txtdisplay = "4"
Case "What is up?!": txtdisplay = "5"
Case "What is your name?": txtdisplay = "6"
End Select
End Select
End Select

End Sub
 

J0n

N/A
Joined
Aug 28, 2003
Messages
410
Gender
Male
HSC
2004
You could use a two-dimensional array, using one dimension as the different languages, and another for the different phrases. If you had one combobox containing the different languages, and one with the phrases, it could be as easy as:

txtDisplay.text = Phrases(cmbLanguage.ListIndex, cmbGreeting.ListIndex)

Where Phrases(X,Y) would be your two-dimensional array where each language would have a different X, and each phrase a different Y.
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
Originally posted by wrx
cant i do a case within a case? my friend said u could do it and he did, but i cant seem to get it to work.
But why would you, JOn's method seems so structured, it's a good solution, you'll have a nested case statement and it would turn out to be a fat block of code.
 

J0n

N/A
Joined
Aug 28, 2003
Messages
410
Gender
Male
HSC
2004
Did you declare the array? i.e.
Dim Phrases(4,6) as String 'If you have 4 languages and 6 phrases for each language
And then did you populate the array?
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
hmmm i guess you could hardcode the phrases
 

velox

Retired
Joined
Mar 19, 2004
Messages
5,521
Location
Where the citi never sleeps.
Gender
Male
HSC
N/A
i got the array working thanks to u guyz :) but if i leave the language combo alone and choose a language, i get an error subscript out of range.when i click debug it shows me this

txtdisplay.Text = Phrases(cmblanguage.ListIndex, cmbgreeting.ListIndex)

i thinks its cos there is no list index for the text "greeting" that is displayed in the combo automatically. The text of my combo is greeting. Im not sure how to fix it, i thought i could make it one like the greetings and assign an index to it and then make a msgbox come up. but then it wont show the text when the prgram starts up. thanks guyz
 

J0n

N/A
Joined
Aug 28, 2003
Messages
410
Gender
Male
HSC
2004
Originally posted by wrx
i got the array working thanks to u guyz :) but if i leave the language combo alone and choose a language, i get an error subscript out of range.when i click debug it shows me this

txtdisplay.Text = Phrases(cmblanguage.ListIndex, cmbgreeting.ListIndex)

i thinks its cos there is no list index for the text "greeting" that is displayed in the combo automatically. The text of my combo is greeting. Im not sure how to fix it, i thought i could make it one like the greetings and assign an index to it and then make a msgbox come up. but then it wont show the text when the prgram starts up. thanks guyz
Actually, i think the default index for the ComboBox is -1, so if you can check for that, you will be able to tell them something like "choose a language/greeting".
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top