【问题标题】:How to Show Image based on Current Culture如何根据当前文化显示图像
【发布时间】:2014-08-07 16:59:44
【问题描述】:

根据用户设备上的当前语言设置,我想在 CustomMessageBox 中显示包含文本的图像。我不想犯错误,向用户展示他们无法理解或识别的语言的图像。我意识到System.GlobalizationCurrentCultureCurrentUICulture 中有两个选项。我想确保我根据用户期望看到的内容向用户显示正确的图像。我不确定要使用哪个,以及具体的区别。我知道用户可以拥有一个文化集和不同的 UI 文化集。

C#

//string resourceLanguage = System.Globalization.CultureInfo.CurrentCulture.ToString();
string resourceLanguage = System.Globalization.CultureInfo.CurrentUICulture.ToString();
            string imagePath = "Assets/Screenshots/" + resourceLanguage + "/" + Constants.inAppScreenshot + ".png";
            CustomMessageBoxContent cmbc = new CustomMessageBoxContent(); //a custom class I defined to handle the image

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Caption = "\n" + AppResources.App_Caption,
                Message = "\n" + AppResources.App_Message + "\n",
                LeftButtonContent = AppResources.App_OK,
                Content = cmbc.CreateImage(imagePath),
                FlowDirection = App.flow
            };

            ...

【问题讨论】:

    标签: c# windows-phone-8 globalization currentculture currentuiculture


    【解决方案1】:

    你可以阅读这个http://forums.asp.net/post/1080435.aspx

    简而言之,CurrentCulture 与货币和日期的格式有关。而CurrentUICulture 与程序使用的资源管理器有关。

    人们可能出于多种原因更改这两种格式,也许他们想要法语的日期格式,而希望使用英语的 Windows 应用程序。或者他们想玩一个只能用日语运行并且他们有西班牙日期格式的游戏。

    最好的选择是选择CurrentUICulture,因为有时计算机的默认日期格式与用户所在国家/地区不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多