英文:
How can the date be formatted using Spanish month names and day names in MAUI
问题
在使用.NET Framework进行开发时,我只需在应用程序(Winforms或Web)的开头设置CurrentUICulture为"es-CL"等文化。这样,整个应用程序中的日期格式都会更改为"es-CL"(月份和日期名称为西班牙语,小数分隔符为",",千位分隔符为"。")。那真是太棒了。
我如何在MAUI中实现相同的效果?我不关心创建多语言应用程序,所以是否有一种简单的方法可以做到这一点?我不想为仅一个语言创建一个resx文件。
谢谢
Jaime
英文:
When I used to develop using .NET Framework, I just set the CurrentUICulture at the beginning of the application (Winforms or Web) to a culture such as "es-CL". With that, all date formatting accross the whole application changes to "es-CL" (month and day names in Spanish, decimal separator as the "," and thousand separator as the "."). That was extraordinary.
How can I achieve the same in MAUI? I don't care about creating a multi language application, so, is there an easy way to do this? I don't want to create a resx file for just one language.
Thanks
Jaime
答案1
得分: 1
CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("es-CL");
在MauiProgram.cs文件中使用时有效。
英文:
@ToolmakerSteve thanks. It worked when I use
CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("es-CL");
in MauiProgram.cs file.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论