在Abp框架.NET Core 3中使用非英语文化的公历日期

问题描述 投票:1回答:1

[当更改ASP.net样板语言(带有Angular的.NET core 3)中的语言时,UI中的日期已更改为Ar Culture,我想将Gregorian Date与Ar Culture一起使用。是否有没有很多变通办法的直接解决方案,我在建议解决方案下面找到了解决方案,但我不喜欢这样的解决方案

https://forum.aspnetboilerplate.com/viewtopic.php?p=26993

编辑(更多详细信息):

在Abp框架中有一个多语言选项,所以当我将语言切换为阿拉伯语时,整个系统文化都切换为具有Hijri日期格式的阿拉伯文化,我想将系统更改为具有公历日期的阿拉伯文化,我如何这样做,如果有定制的代码,我应该放在哪里(例如在Startup.cs类中),因为我尝试了定制的代码,但系统在Startup.cs类的Configure Function中不接受它。

Startup.cs类代码

 public void Configure(IApplicationBuilder app,  ILoggerFactory loggerFactory)
        {
/*****************************************************************************/

            CultureInfo myCIintl = new CultureInfo("ar-SA", false);
            Calendar[] myOptCals = new CultureInfo("ar-SA").OptionalCalendars;
            // Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
            Console.WriteLine("The ar-SA culture supports the following calendars:");
            foreach (Calendar cal in myOptCals)
            {

                if (cal.GetType() == typeof(GregorianCalendar))
                {

                    GregorianCalendar myGreCal = (GregorianCalendar)cal;
                    myCIintl.DateTimeFormat.Calendar = myGreCal;
                    GregorianCalendarTypes calType = myGreCal.CalendarType;
                    Console.WriteLine("   {0} ({1})", cal, calType);
                }
                else
                {
                    Console.WriteLine("   {0}", cal);
                }
            }
/*****************************************************************************/

            app.UseAbp(options => { options.UseAbpRequestLocalization = false; }); // Initializes ABP framework.

            app.UseCors(_defaultCorsPolicyName); // Enable CORS!

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAbpRequestLocalization();


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub<AbpCommonHub>("/signalr");
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
            });

            // Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger();
            // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint(_appConfiguration["App:ServerRootAddress"].EnsureEndsWith('/') + "swagger/v1/swagger.json", "MyApp API V1");
                options.IndexStream = () => Assembly.GetExecutingAssembly()
                    .GetManifestResourceStream("MyApp .Web.Host.wwwroot.swagger.ui.index.html");
            }); // URL: /swagger
        }
asp.net-core aspnetboilerplate asp.net-boilerplate
1个回答
0
投票

我找到了解决方案(简单的解决方法:):

首先,如果您想要一个丰富的链接审阅this link,但我所做的是:

1-转到AbpLanguages数据库表并删除所有记录。

2-在DefaultLanguagesCreator类中,将ar更改为ar-EG,因为ar文化的默认日历是System.Globalization.UmAlQuraCalendar,但ar-EG] >为它设置默认日历为System.Globalization.GregorianCalendar(我想要的日历)

3-然后清理,重新生成解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.