Website show wrong month for julyin arabic, this is Arabic website developed in asp.net webform and culture is set properly to 'ar-AE' and event date shows correct month on local machine but on productions it show month which belongs to Egyptian culture
Date in database is stored as smalldatetime in this format 2017-07-25 00:00:00
Wrong month for July
Correct month on local-host :25 يوليو 2017
Wrong month on production : 25 يوليه 2017
<asp:Label ID="lblDate" runat="server" Text='<%# FormatDate(Eval("PublishDate")) %>'>
</asp:Label>
protected string FormatDate(object dt) {
string date = String.Format("{0:MMMM dd, yyyy}", dt);
date = String.Format("{0:dd MMMM yyyy}", dt);
// Response.Write(date + "<br/>");
return date;
}
Culture is set to UAE correctly
protected override void InitializeCulture() {
String lang = "ar-AE";
CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentUICulture;
// Call function to detect Language and assign to session variable
Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
base.InitializeCulture();
}
What could be the reason, could it be production server itself?
We check almost all possibilities and tried everything, it just gets wrong month for July rest all is ok.
I also cross check production server Language setting, IIS settings, it all seems to be okay, only thing i can point is that server has all latest updates, may be we are missing something. we tested same on different windows 7 machine it just works fine.
Update: I have tried solution suggest also but it keeps showing wrong month for JULY يوليه. This is wrong. We tested it also it show the correct culture on the server.
Fiddle example also show wrong month https://dotnetfiddle.net/ZAOJ7H
I tried to find localized
DateTimemonth name by using these lines of code:The resulted code gives
يوليهinstead ofيوليو, indicating something went wrong in Windows localization of Gregorian month names in Arabic language.By finding out a little bit, it caused by
locale.nlsfile located in%WINDIR%\System32\locale.nlscontaining incorrect data where the month of July is displayed in other Arabic version than current system culture using.Since NLS file is formatted in binary, it's hard to read and edit stored locale information even viewing it in hex editor. AFAIK, this problem already fixed by Microsoft in KB981981 update for Windows 7 & Server 2008 R2 systems, you can perform update depending on platform used (requires restart afterwards):
Update for Windows 7 32-bit (KB981981) - 5/24/2010
Update for Windows 7 64-bit (KB981981) - 5/24/2010
NB: Ensure that all affected machines installed with this update for best result. If you can't install the update due to certain restrictions, I suggest to try using jQuery plugin for
datepickerwhich showsيوليوfor month of July as workaround.PS: I also tried zahed's solution in the OP's fiddle -
But it shows
25 الثلاثاء , يوليه, 2017(i.e.يوليه) too, hence it's not the string formatting problem, instead the Windows localization problem as explained above.References:
Description of Software Update Services and Windows Server Update Services changes in content for 2010
How to convert the month name in english text in datetime to arabic text using C#?
Related:
Michael S. Kaplan - Arabic locales for month names