1

When changing the language in ASP.net boilerplate (.NET core 3 with Angular) the date in the UI has been changed to Ar Culture I wanna use Gregorian Date with Ar Culture. Is there any straight forward solution without lots of workarounds I found below suggestions solution but I don't prefer such that solutions

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

Edited (more details):

in Abp framework there is a multi-language option, So when I switch the language to Arabic the whole system culture switched to Arabic culture with Hijri date format, I want to change the system to Arabic culture with gregorian date, How Could I do that and if there is a customized code where should I put it (for example in Startup.cs class) because I've tried customized code but the system didn't accept it in Configure Function in Startup.cs class

Startup.cs class code

 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
        }
Abdulaziz
  • 654
  • 3
  • 12
  • 37
  • Boilerplate is just a third-party framework. It doesn't change how ASP.NET Core itself works with dates. What are you actually trying to do? I suspect there are a *lot* of duplicate questions that say "you can't do that". PS: The certificate on that page is expired. Explain what you want in the question itself – Panagiotis Kanavos Feb 24 '20 at 14:25
  • PPS: Given that Boilerplate is an ASP.NET framework and that link is clearly a PHP page, that returns a certificate expiration error, don't expect people to touch that link with anything short of hazmat suits – Panagiotis Kanavos Feb 24 '20 at 14:26
  • 1
    Have you checked [How to: Display Dates in Non-Gregorian Calendars](https://learn.microsoft.com/en-us/dotnet/standard/base-types/how-to-display-dates-in-non-gregorian-calendars)? Dates have no culture, they have calendars. The DateTime is treated internally as a Gregorian date, no matter the Calendar. Perhaps all you need to do is change the *format string* used to display dates? Or use a custom culture that uses a different Date format string? – Panagiotis Kanavos Feb 24 '20 at 14:32
  • @PanagiotisKanavos than you, I've added more details could you, please check it? – Abdulaziz Feb 24 '20 at 16:58
  • Any new information? – Abdulaziz Feb 25 '20 at 06:57

1 Answers1

3

I found the solution (easy workaround solution):

first of all, if you want a rich of information related to date and calendar review this link but what I did is:

1- Go to AbpLanguages database table and delete all records.

2- In DefaultLanguagesCreator class change the ar to ar-EG because the default calendar for ar Culture is System.Globalization.UmAlQuraCalendar but ar-EG culture the default calendar for it is System.Globalization.GregorianCalendar (the calendar that I want)

3- then clean, rebuild the solution.

4- Don't forget to change the culture inside the XML localization file to ar-EG.

Abdulaziz
  • 654
  • 3
  • 12
  • 37