Common Phrases - Quick Language Select

I use these phrases quiet often. Because of this I spend a lot of time in Google Translate. I am trying to make things a little faster by having a script ready with the phrases.
I have this wrote up and it works, but it is a bit lengthly. I am sure there is a more stable and efficient way to do this. Can someone take a look and tell me what you think.

property theLanguage : {"English", "Spanish", "Portuguese", "French"}
property curLanguage : 1
property theStatements : {"Hello", "Does anyone need help?", "Does anyone want to play a game?", "I don't understand", "Do you speak English?", "I don't speak language.", "I'm sorry", "Yes", "No", "Language Select"}
property sayHello : {"Hello", "Hola", "Olá", "Bonjour"}
property askHelp : {"Does anyone need help?", "Es necesario que alguien ayudarme?", "Será que alguém precisa de ajuda?", "T besoin de personne d'aide?"}
property askGame : {"Does anyone want to play a game?", "Alguien quiere jugar un juego?", "Alguém quer jogar um jogo?", "Quelqu'un veut-il jouer à un jeu?"}
property noUnderstand : {"I don't understand", "No entiendo", "Eu não entendo", "Je ne comprends pas"}
property speak : {"Do you speak English?", "Hablas Inglés?", "Você fala Inglês?", "Parlez-vous anglais?"}
property dontSpeak : {"I don't speak English", "Yo no hablo español", "Eu não falo Português", "Je ne parle pas français"}
property ImSorry : {"I'm sorry", "Lo siento", "Sinto muito", "Je suis désolé"}
property sayYes : {"yes", "sí", "sim", "oui"}
property sayNo : {"no", "en", "no", "dans"}
set meRunning to true

repeat while meRunning
	activate me
	
	set theOption to ""
	set theResponse to ""
	set theOption to (choose from list theStatements with prompt "Select Statement - " & (item curLanguage of theLanguage) & ":") as string
	if theOption is "false" then error number -128
	if theOption is (item 1 of theStatements) then
		set theResponse to (item curLanguage of sayHello)
	else if theOption is (item 2 of theStatements) then
		set theResponse to (item curLanguage of askHelp)
	else if theOption is (item 3 of theStatements) then
		set theResponse to (item curLanguage of askGame)
	else if theOption is (item 4 of theStatements) then
		set theResponse to (item curLanguage of noUnderstand)
	else if theOption is (item 5 of theStatements) then
		set theResponse to (item curLanguage of speak)
	else if theOption is (item 6 of theStatements) then
		set theResponse to (item curLanguage of dontSpeak)
	else if theOption is (item 7 of theStatements) then
		set theResponse to (item curLanguage of ImSorry)
	else if theOption is (item 8 of theStatements) then
		set theResponse to (item curLanguage of sayYes)
	else if theOption is (item 9 of theStatements) then
		set theResponse to (item curLanguage of sayNo)
	else if theOption is (item 10 of theStatements) then
		set pickLanguage to (choose from list theLanguage with prompt "Select Language") as string
		if pickLanguage is "false" then error number -128
		set curLanguage to 0
		repeat with i from 1 to number of items in theLanguage
			set x to item i of theLanguage
			set curLanguage to curLanguage + 1
			if x is pickLanguage then exit repeat
		end repeat
		
	end if
	set the clipboard to (theResponse as text)
end repeat

property theLanguage : {"English", "Spanish", "Portuguese", "French"}
property curLanguage : 1
property theStatements : {"Hello", "Does anyone need help?", "Does anyone want to play a game?", "I don't understand", "Do you speak English?", "I don't speak language.", "I'm sorry", "Yes", "No", "Language Select"}
property sayHello : {"Hello", "Hola", "Olá", "Bonjour"}
property askHelp : {"Does anyone need help?", "Es necesario que alguien ayudarme?", "Será que alguém precisa de ajuda?", "T besoin de personne d'aide?"}
property askGame : {"Does anyone want to play a game?", "Alguien quiere jugar un juego?", "Alguém quer jogar um jogo?", "Quelqu'un veut-il jouer à un jeu?"}
property noUnderstand : {"I don't understand", "No entiendo", "Eu não entendo", "Je ne comprends pas"}
property speak : {"Do you speak English?", "Hablas Inglés?", "Você fala Inglês?", "Parlez-vous anglais?"}
property dontSpeak : {"I don't speak English", "Yo no hablo español", "Eu não falo Português", "Je ne parle pas français"}
property ImSorry : {"I'm sorry", "Lo siento", "Sinto muito", "Je suis désolé"}
property sayYes : {"yes", "sí", "sim", "oui"}
property sayNo : {"no", "no", "no", "non"}
property phraseBook : {sayHello, askHelp, askGame, noUnderstand, speak, dontSpeak, ImSorry, sayYes, sayNo}

repeat
	activate
	
	set theOption to (choose from list theStatements with prompt "Select Statement - " & (item curLanguage of theLanguage) & ":")
	if (theOption is false) then error number -128
	set theOption to beginning of theOption
	if (theOption is (item -1 of theStatements)) then
		set pickLanguage to (choose from list theLanguage with prompt "Select Language")
		if (pickLanguage is false) then error number -128
		set pickLanguage to beginning of pickLanguage
		set curLanguage to 0
		repeat with i from 1 to (count theLanguage)
			if (pickLanguage is (item i of theLanguage)) then
				set curLanguage to i
				exit repeat
			end if
		end repeat
	else
		repeat with i from 1 to (count theStatements) - 1
			if (theOption is item i of theStatements) then
				set theResponse to (item curLanguage of item i of phraseBook)
				exit repeat
			end if
		end repeat
		set the clipboard to theResponse
	end if
end repeat

I’d almost recommend checking that all those phrases are correct. :wink:

Thanks for taking a look! I rand every phrase through Google Translate, they all come back right. Do you know which looks wrong?

I thought this looked useful, and I was trying out the script Nigel posted, but when I pick “Select Language” no matter what language I pick, shows English phrases…

My script did that as well. This way what ever language you select you can read the English version. The script copies the foreign version to the clipboard. :smiley:

Ah right! Now I understand! Silly me… :rolleyes:

You could set the property thestatements to {}
and then do a repeat that uses curLanguage to select the appropriate phrase. I am writing up somehting from you now, debugging it =).

repeat with i from 1 to (count phraseBook)
	set thePhrase to (item i of phraseBook)
	display dialog thePhrase
	set theMessage to (item curLanguage of thePhrase)
	copy theMessage to end of list theStatements
end repeat

Getting error though. But basically something like that.

Here we go! With the tastey goodness of changing the language on the main list. Only problem is what you see on the main list is what gets copied to the clipboard instead of your language of choice… Give me a moment and I can fix that XD

property theLanguage : {"English", "Spanish", "Portuguese", "French"}
property curLanguage : 1
--property theStatements : {"Hello", "Does anyone need help?", "Does anyone want to play a game?", "I don't understand", "Do you speak English?", "I don't speak language.", "I'm sorry", "Yes", "No", "Language Select"}
property theStatements : {}
property sayHello : {"Hello", "Hola", "Olá", "Bonjour"}
property askHelp : {"Does anyone need help?", "Es necesario que alguien ayudarme?", "Será que alguém precisa de ajuda?", "T besoin de personne d'aide?"}
property askGame : {"Does anyone want to play a game?", "Alguien quiere jugar un juego?", "Alguém quer jogar um jogo?", "Quelqu'un veut-il jouer à un jeu?"}
property noUnderstand : {"I don't understand", "No entiendo", "Eu não entendo", "Je ne comprends pas"}
property speak : {"Do you speak English?", "Hablas Inglés?", "Você fala Inglês?", "Parlez-vous anglais?"}
property dontSpeak : {"I don't speak English", "Yo no hablo español", "Eu não falo Português", "Je ne parle pas français"}
property ImSorry : {"I'm sorry", "Lo siento", "Sinto muito", "Je suis désolé"}
property sayYes : {"yes", "sí", "sim", "oui"}
property sayNo : {"no", "no", "no", "non"}
property phraseBook : {sayHello, askHelp, askGame, noUnderstand, speak, dontSpeak, ImSorry, sayYes, sayNo}

setLanguage()

repeat
	
	
	activate
	
	set theOption to (choose from list theStatements with prompt "Select Statement - " & (item curLanguage of theLanguage) & ":")
	if (theOption is false) then error number -128
	set theOption to beginning of theOption
	if (theOption is (item -1 of theStatements)) then
		set pickLanguage to (choose from list theLanguage with prompt "Select Language")
		if (pickLanguage is false) then error number -128
		set pickLanguage to beginning of pickLanguage
		set curLanguage to 0
		repeat with i from 1 to (count theLanguage)
			if (pickLanguage is (item i of theLanguage)) then
				set curLanguage to i
				exit repeat
			end if
		end repeat
		setLanguage()
	else
		repeat with i from 1 to (count theStatements) - 1
			if (theOption is item i of theStatements) then
				set theResponse to (item curLanguage of item i of phraseBook)
				exit repeat
			end if
		end repeat
		set the clipboard to theResponse
	end if
end repeat

on setLanguage()
	set theStatements to {}
	repeat with i from 1 to (count phraseBook)
		set thePhrase to (item i of phraseBook)
		--display dialog thePhrase
		set theMessage to (item curLanguage of thePhrase)
		copy theMessage to end of theStatements
	end repeat
	copy "Language Select" to end of theStatements
end setLanguage

Here we go magikseb! With My Language Select and Foreign Language Select

property theLanguage : {"English", "Spanish", "Portuguese", "French"}
property curLanguage : 1
property forLanguage : 1
--property theStatements : {"Hello", "Does anyone need help?", "Does anyone want to play a game?", "I don't understand", "Do you speak English?", "I don't speak language.", "I'm sorry", "Yes", "No", "Language Select"}
property theStatements : {}
property sayHello : {"Hello", "Hola", "Olá", "Bonjour"}
property askHelp : {"Does anyone need help?", "Es necesario que alguien ayudarme?", "Será que alguém precisa de ajuda?", "T besoin de personne d'aide?"}
property askGame : {"Does anyone want to play a game?", "Alguien quiere jugar un juego?", "Alguém quer jogar um jogo?", "Quelqu'un veut-il jouer à un jeu?"}
property noUnderstand : {"I don't understand", "No entiendo", "Eu não entendo", "Je ne comprends pas"}
property speak : {"Do you speak English?", "Hablas Inglés?", "Você fala Inglês?", "Parlez-vous anglais?"}
property dontSpeak : {"I don't speak English", "Yo no hablo español", "Eu não falo Português", "Je ne parle pas français"}
property ImSorry : {"I'm sorry", "Lo siento", "Sinto muito", "Je suis désolé"}
property sayYes : {"yes", "sí", "sim", "oui"}
property sayNo : {"no", "no", "no", "non"}
property phraseBook : {sayHello, askHelp, askGame, noUnderstand, speak, dontSpeak, ImSorry, sayYes, sayNo}

setLanguage()

repeat
	
	
	activate
	
	set theOption to (choose from list theStatements with prompt "Select Statement - " & (item curLanguage of theLanguage) & " / " & (item forLanguage of theLanguage) & ":")
	if (theOption is false) then error number -128
	set theOption to beginning of theOption
	if (theOption is (item 10 of theStatements)) then
		set pickLanguage to (choose from list theLanguage with prompt "Select My Language")
		if (pickLanguage is false) then error number -128
		set pickLanguage to beginning of pickLanguage
		set curLanguage to 0
		repeat with i from 1 to (count theLanguage)
			if (pickLanguage is (item i of theLanguage)) then
				set curLanguage to i
				exit repeat
			end if
		end repeat
		setLanguage()
	else if (theOption is (item 11 of theStatements)) then
		set pickLanguage to (choose from list theLanguage with prompt "Select Foreign Language")
		if (pickLanguage is false) then error number -128
		set pickLanguage to beginning of pickLanguage
		set forLanguage to 0
		repeat with i from 1 to (count theLanguage)
			if (pickLanguage is (item i of theLanguage)) then
				set forLanguage to i
				exit repeat
			end if
		end repeat
		setLanguage()
	else
		repeat with i from 1 to (count theStatements) - 1
			if (theOption is item i of theStatements) then
				set theResponse to (item forLanguage of item i of phraseBook)
				exit repeat
			end if
		end repeat
		set the clipboard to theResponse
	end if
end repeat

on setLanguage()
	set theStatements to {}
	repeat with i from 1 to (count phraseBook)
		set thePhrase to (item i of phraseBook)
		--display dialog thePhrase
		set theMessage to (item curLanguage of thePhrase)
		copy theMessage to end of theStatements
	end repeat
	copy "My Language" to end of theStatements
	copy "Foreign Language" to end of theStatements
end setLanguage

and now with a settings menu

property theLanguage : {"English", "Spanish", "Portuguese", "French"}
property curLanguage : 1
property forLanguage : 1
--property theStatements : {"Hello", "Does anyone need help?", "Does anyone want to play a game?", "I don't understand", "Do you speak English?", "I don't speak language.", "I'm sorry", "Yes", "No", "Language Select"}
property theStatements : {}
property sayHello : {"Hello", "Hola", "Olá", "Bonjour"}
property askHelp : {"Does anyone need help?", "Es necesario que alguien ayudarme?", "Será que alguém precisa de ajuda?", "T besoin de personne d'aide?"}
property askGame : {"Does anyone want to play a game?", "Alguien quiere jugar un juego?", "Alguém quer jogar um jogo?", "Quelqu'un veut-il jouer à un jeu?"}
property noUnderstand : {"I don't understand", "No entiendo", "Eu não entendo", "Je ne comprends pas"}
property speak : {"Do you speak English?", "Hablas Inglés?", "Você fala Inglês?", "Parlez-vous anglais?"}
property dontSpeak : {"I don't speak English", "Yo no hablo español", "Eu não falo Português", "Je ne parle pas français"}
property ImSorry : {"I'm sorry", "Lo siento", "Sinto muito", "Je suis désolé"}
property sayYes : {"yes", "sí", "sim", "oui"}
property sayNo : {"no", "no", "no", "non"}
property phraseBook : {sayHello, askHelp, askGame, noUnderstand, speak, dontSpeak, ImSorry, sayYes, sayNo}

setLanguage()

repeat
	activate
	set theOption to (choose from list theStatements with prompt "Select Statement - " & (item curLanguage of theLanguage) & " / " & (item forLanguage of theLanguage) & ":")
	if (theOption is false) then error number -128
	set theOption to beginning of theOption
	if (theOption is (item -1 of theStatements)) then
		set setList to {"My Language", "Foreign Language"}
		set theSetting to (choose from list setList with prompt "**Settings**") as string
		--	if (theSetting is false) then error number -128
		if theSetting is (item 1 of setList) then
			set pickLanguage to (choose from list theLanguage with prompt "Select My Language")
			if (pickLanguage is false) then error number -128
			set pickLanguage to beginning of pickLanguage
			set curLanguage to 0
			repeat with i from 1 to (count theLanguage)
				if (pickLanguage is (item i of theLanguage)) then
					set curLanguage to i
					exit repeat
				end if
			end repeat
			setLanguage()
		else if theSetting is (item 2 of setList) then
			set pickLanguage to (choose from list theLanguage with prompt "Select Foreign Language")
			if (pickLanguage is false) then error number -128
			set pickLanguage to beginning of pickLanguage
			set forLanguage to 0
			repeat with i from 1 to (count theLanguage)
				if (pickLanguage is (item i of theLanguage)) then
					set forLanguage to i
					exit repeat
				end if
			end repeat
			setLanguage()
		end if
	else
		repeat with i from 1 to (count theStatements) - 1
			if (theOption is item i of theStatements) then
				set theResponse to (item forLanguage of item i of phraseBook)
				exit repeat
			end if
		end repeat
		set the clipboard to theResponse
	end if
end repeat

on setLanguage()
	set theStatements to {}
	repeat with i from 1 to (count phraseBook)
		set thePhrase to (item i of phraseBook)
		--display dialog thePhrase
		set theMessage to (item curLanguage of thePhrase)
		copy theMessage to end of theStatements
	end repeat
	copy "**Settings**" to end of theStatements
end setLanguage

Two of the "no"s were wrong in your original script. My Spanish is a little rusty, but “Es necesario que alguien ayudarme?” looks as though it means “Is it necessary for anyone to help me?” (ie. “Does anyone need (to) help?” rather than “Does anyone need (any) help?”) The French for that phrase is certainly gibberish. It could possibly be “Est-ce que quelqu’un a besoin d’aide?” ” but maybe Yvan will see this thread and offer some suggestions.

WEIRD! If I leave the quotes on Es necesario que alguien ayudarme? It comes back as you say if I remove the quotes it comes back as Someone need help?