1

So, il get straight to the point Ive got 2 questions

First: How can i enable multi languages in C# Application? For example i wrote this:

static void Main()
{
    Console.WriteLine("Dude, what's up?"); //English
    Console.WriteLine("אחי, מה קורה?"); //Hebrew
    Console.WriteLine("好傢伙,這是怎麼回事?"); //Chinese
    Console.WriteLine("おい、最大何ですか?"); //Japanese
    string answer = Console.ReadLine();

    if (answer.Language == Hebrew)
        Console.WriteLine("You wrote on: {0}", answer.Language);
    else if (answer.Language == Japanese)
        //Do something else...
    //And so on and on...

    Console.ReadKey();
}

And it print me on the cmd.exe this:

So, how can i enable the hebrew and chinese and more languages in my C# application?

And my second question is:

How can i get the language of the string?

    if (answer.Language == Hebrew)
        Console.WriteLine("You wrote on: {0}", answer.Language);
    else if (answer.Language == Japanese)
        //Do something else...
Community
  • 1
  • 1
Pinkie Pie
  • 61
  • 4
  • there is no reliable way to get the language of a string. – Daniel A. White Mar 11 '15 at 12:36
  • (aside: that should have been a separate question) – Daniel A. White Mar 11 '15 at 12:36
  • In answer to your second question, not covered by the dupe question, strings do not have a "Language" - they're just a sequence of bytes. – Jamiec Mar 11 '15 at 12:37
  • Yeah i know that, but there are maybe something like System.language.get(string) or i dont know and what about using the other languages like hebrew and chinese? – Pinkie Pie Mar 11 '15 at 12:56
  • @HenMadhala - There is nothing like that built in. Google translate manages to "detect" a language with quite some degree of accuracy, but thats [far more complex than you might imagine](http://www.quora.com/How-does-Google-Translate-detect-language-on-the-fly). When a console app is running with a logged in user, you can [detect what they have specified as their default, and other installed, language packs](http://stackoverflow.com/questions/479300/detect-os-language-from-c-sharp). Perhaps that might be of use to you. – Jamiec Mar 11 '15 at 14:26
  • This is not an exact duplicate because setting OutputEncoding will not make it for all languages, this link will fork for Chinese, and similar procedure should work for Japanese and Hebrew: https://stackoverflow.com/a/54327996/378783 – watbywbarif Jan 23 '19 at 13:17
  • Please share if you find font which will work for all 3 languages on Windows 10, i have only tried KaiTi for Chinese, it would be interesting to know which one will work with Japanese and Hebrew also. – watbywbarif Jan 23 '19 at 13:21

0 Answers0