Is this possible with unity? SImple translator

What I’m looking for is to ‘code’ a simple translator.
Basically 2 text fields,a translate button, and a code that is more of less like this:

if varx = h
print "hello"
elseif varx = b
print "bye"
else varx = n
print "none"

Obviously this code isn’t going to work but I’m looking for guidance on how to do this(not the actual solution, just the “direction” on where to head.).

Thanks advance.

Interestingly, I just added support for localization to my own Unity Project :stuck_out_tongue:

The general idea, instead of hard-coding if/elses, you’d want to set up a Dictionary/Map/Hashtable that basically has a list of string key/value pairs, and just pull the value based on the key. You can then load those pairs from an external file to allow to add/change translations without needing to recode anything, like this:

protected Dictionary<string, string> _TextTable = new Dictionary<string,string>();
public void Load()
{
	//... load from file or something
}
public string GetValue( string key )
{
	if( _TextTable.ContainsKey(key) )
	{
		return _TextTable[key];
	}
	Debug.LogError("Key " + key + " not found in text table!");
	return "";
}

The problem you are looking at is well known in games and is commonly referred to as “Localization” so just google “unity + localization” and you should find more info.

I actually want to stay with my original example and hard-code if/else into two text fields.
I’m still trying to figure this out.

Thanks for helping.

006, out of curiosity, why do you want to hard code the translations?