A particular application may refer to a specific property in one of three languages in different contexts: in lowercase English, in uppercase English, and in Hebrew. To facilitate ease of converting one language to another, this monstrosity exists:
public string translatePersonType(string personType, string lang)
{
switch (personType)
{
case "employee":
case "EMPLOYEE":
case "עובד":
switch (lang)
{
case "eng":
return "employee";
case "ENG":
return "EMPLOYEE";
case "heb":
return "עובד";
}
break;
case "contractor":
case "CONTRACTOR":
case "קבלן":
switch (lang)
{
case "eng":
return "contractor";
case "ENG":
return "CONTRACTOR";
case "heb":
return "קבלן";
}
break;
case "supplier":
case "SUPPLIER":
case "ספק":
switch (lang)
{
case "eng":
return "supplier";
case "ENG":
return "SUPPLIER";
case "heb":
return "ספק";
}
break;
case "customer":
case "CUSTOMER":
case "לקוח":
switch (lang)
{
case "eng":
return "customer";
case "ENG":
return "CUSTOMER";
case "heb":
return "לקוח";
}
break;
default:
return "";
}// end switch (personType)
return "";
}// end translatePersonType
Can this be refactored to be more concise and maintainable? For reference, this is the database field behind the property:
personType SET('CUSTOMER','SUPPLIER','EMPLOYEE', 'CONTRACTOR') NOT NULL
Thanks.