多语言设置,获取对应的资源文件配置

class Program
    {
        static void Main(string[] args)
        {
            var isContinue = true;
            while (isContinue)
            {
                Console.WriteLine("请输入Language Code:");
                var languageCode = Console.ReadLine();

                //languageCode一般有zh-CN,zh-Hant,zh-Hans,ja-JP,en,en-US等,
                //这样就能匹配到对应的资源文件了,如R.zh-Hans,R.zh-Hant,R.ja-JP,R等
                CultureInfo culture = new CultureInfo(languageCode);

                Thread.CurrentThread.CurrentCulture = culture;
                Thread.CurrentThread.CurrentUICulture = culture;

                Console.WriteLine(R.Name);

                Console.WriteLine("是否继续?Y/N: ");
                isContinue = string.Equals("Y", Console.ReadLine(), StringComparison.OrdinalIgnoreCase);
            }
        }
    }

 

posted on 2018-11-12 15:05  itjeff  阅读(165)  评论(0编辑  收藏  举报

导航