I
iHandler
Guest
I got a class called Translate() and it works perfectly fine. The problems are
1. As more languages are to be added, this class becomes very "bulky", and this makes it very hard to maintain.
2. The "base language" is English. Each language must have a base language which is actually duplicated. How can it possible make a single base language (i.e. English) across all different translated languages?
Here below is the coding:
public class Translate
{
public enum Language
{
French,
German,
Spanish,
Italian
}
public static string GetTranslate(string text, Language language)
{
switch (language)
{
case Language.French:
text = text.Replace("Black", "Noir");
text = text.Replace("Blue", "Bleu");
text = text.Replace("Brown", "Marron");
text = text.Replace("Green", "Vert");
text = text.Replace("Gold", "Or");
text = text.Replace("Pink", "Rose");
text = text.Replace("Red", "Rouge");
text = text.Replace("Silver", "Argent");
text = text.Replace("Yellow", "Jaune");
text = text.Replace("White", "Blanc");
break;
case Language.German:
text = text.Replace("Black", "Schwarz");
text = text.Replace("Blue", "Blau");
text = text.Replace("Brown", "Braun");
text = text.Replace("Green", "Grün");
text = text.Replace("Gold", "Gold");
text = text.Replace("Light", "Licht");
text = text.Replace("Pink", "Rosa");
text = text.Replace("Red", "rot");
text = text.Replace("Silver", "Silber");
text = text.Replace("Yellow", "Gelb");
text = text.Replace("White", "Weiß");
text = text.Replace("Assorted", "mischen");
break;
case Language.Spanish:
text = text.Replace("Black", "Negra");
text = text.Replace("Blue", "Azul");
text = text.Replace("Brown", "marrón");
text = text.Replace("Green", "Verde");
text = text.Replace("Gold", "Oro");
text = text.Replace("Pink", "Rosada");
text = text.Replace("Red", "Roja");
text = text.Replace("Silver", "Plata");
text = text.Replace("Yellow", "Amarilla");
text = text.Replace("White", "Blanca");
text = text.Replace("Assorted", "surtido");
break;
case Language.Italian:
text = text.Replace("Black", "Nero");
text = text.Replace("Blue", "Blu");
text = text.Replace("Brown", "Marrone");
text = text.Replace("Green", "verde");
text = text.Replace("Gold", "Oro");
text = text.Replace("Pink", "Rosa");
text = text.Replace("Red", "Rossa");
text = text.Replace("Silver", "Argento");
text = text.Replace("Yellow", "Gialla");
text = text.Replace("White", "Bianca");
text = text.Replace("Assorted", "assortito");
break;
}
return text;
}
}
Thank you for your time, if anyone knows how to correct this, please let me know, thanks
Continue reading...
1. As more languages are to be added, this class becomes very "bulky", and this makes it very hard to maintain.
2. The "base language" is English. Each language must have a base language which is actually duplicated. How can it possible make a single base language (i.e. English) across all different translated languages?
Here below is the coding:
public class Translate
{
public enum Language
{
French,
German,
Spanish,
Italian
}
public static string GetTranslate(string text, Language language)
{
switch (language)
{
case Language.French:
text = text.Replace("Black", "Noir");
text = text.Replace("Blue", "Bleu");
text = text.Replace("Brown", "Marron");
text = text.Replace("Green", "Vert");
text = text.Replace("Gold", "Or");
text = text.Replace("Pink", "Rose");
text = text.Replace("Red", "Rouge");
text = text.Replace("Silver", "Argent");
text = text.Replace("Yellow", "Jaune");
text = text.Replace("White", "Blanc");
break;
case Language.German:
text = text.Replace("Black", "Schwarz");
text = text.Replace("Blue", "Blau");
text = text.Replace("Brown", "Braun");
text = text.Replace("Green", "Grün");
text = text.Replace("Gold", "Gold");
text = text.Replace("Light", "Licht");
text = text.Replace("Pink", "Rosa");
text = text.Replace("Red", "rot");
text = text.Replace("Silver", "Silber");
text = text.Replace("Yellow", "Gelb");
text = text.Replace("White", "Weiß");
text = text.Replace("Assorted", "mischen");
break;
case Language.Spanish:
text = text.Replace("Black", "Negra");
text = text.Replace("Blue", "Azul");
text = text.Replace("Brown", "marrón");
text = text.Replace("Green", "Verde");
text = text.Replace("Gold", "Oro");
text = text.Replace("Pink", "Rosada");
text = text.Replace("Red", "Roja");
text = text.Replace("Silver", "Plata");
text = text.Replace("Yellow", "Amarilla");
text = text.Replace("White", "Blanca");
text = text.Replace("Assorted", "surtido");
break;
case Language.Italian:
text = text.Replace("Black", "Nero");
text = text.Replace("Blue", "Blu");
text = text.Replace("Brown", "Marrone");
text = text.Replace("Green", "verde");
text = text.Replace("Gold", "Oro");
text = text.Replace("Pink", "Rosa");
text = text.Replace("Red", "Rossa");
text = text.Replace("Silver", "Argento");
text = text.Replace("Yellow", "Gialla");
text = text.Replace("White", "Bianca");
text = text.Replace("Assorted", "assortito");
break;
}
return text;
}
}
Thank you for your time, if anyone knows how to correct this, please let me know, thanks
Continue reading...