如何在公历中显示阿拉伯日期? [英] How to display Arabic dates in the Gregorian calendar?

查看:65
本文介绍了如何在公历中显示阿拉伯日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多语言的 ASP.NET 站点;其中一种语言是阿拉伯语 (ar-SA).要在文化之间切换,我使用以下代码:

I have a multilingual ASP.NET site; one of the languages is Arabic (ar-SA). To switch between cultures, I use this code:

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Name)
Thread.CurrentThread.CurrentUICulture = New CultureInfo(Name)

例如,当显示一篇文章的日期时,我只是这样做,本地化 API 会处理一切:

When displaying the date of an article, for example, I just do this, and the localization API takes care of everything:

<%#Eval("DatelineDate","{0:d MMMM yyyy}")%>

问题是这使用 Hijiri(伊斯兰)日历显示日期(例如,2008 年呈现为 1429).客户想要使用公历显示日期(当然,仍然用阿拉伯语呈现月份名称和其他所有内容).我该怎么做?

The problem is that this displays dates using the Hijiri (Islamic) calendar (e.g. the year 2008 is rendered as 1429). The client wants to display the dates using the Gregorian calendar (still rendering the month names and everything else in Arabic, of course). How can I do this?

推荐答案

答案:

结果证明 ar-SA 文化是唯一使用 Hijiri 日历的文化;所有其他阿拉伯文化都使用公历.以下是阿拉伯语的不同日期格式(有点乱,因为 WMD 不支持似乎支持 RTL 文本).

Answer:

Turns out the ar-SA culture is the only one to use the Hijiri calendar; all the other Arabic cultures use Gregorian. Here are the different date formats in Arabic (a bit messed up because WMD doesn't support seem to support RTL text).

ar-AE 11 ديسمبر 2008 
ar-BH 11 ديسمبر 2008 
ar-DZ 11 ديسمبر 2008 
ar-EG 11 ديسمبر 2008 
ar-IQ 11 كانون الأول 2008 
ar-JO 11 كانون الأول 2008 
ar-KW 11 ديسمبر 2008 
ar-LB 11 كانون الأول 2008 
ar-LY 11 ديسمبر 2008 
ar-MA 11 دجنبر 2008 
ar-OM 11 ديسمبر 2008 
ar-QA 11 ديسمبر 2008 
ar-SA 13 ذو الحجة 1429 
ar-SY 11 كانون الأول 2008 
ar-TN 11 ديسمبر 2008 
ar-YE 11 ديسمبر 2008 

对于它的价值,这里是快速&我用来生成这个列表的脏代码:

And for what it's worth here's the quick & dirty code I used to generate this list:

    Response.Write("<table width=300px>")
    For Each ci As CultureInfo In (From c As CultureInfo In CultureInfo.GetCultures(CultureTypes.AllCultures) Order By c.Name Where c.Name.StartsWith("ar-"))
        Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(ci.Name)
        Thread.CurrentThread.CurrentUICulture = New CultureInfo(ci.Name)
        Response.Write(String.Format("<tr><td>{0}</td> <td style='direction:rtl;font-size:20px;'>{1:d MMMM yyyy}</td></tr>", ci.Name, Today))

    Next
    Response.Write("</table>")
    Response.End()

更多文化见 http://www.massimilianobianchi.info/max/articles/22/UI-culture-list-and-codes.aspx

这篇关于如何在公历中显示阿拉伯日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆