我想在支持的 Umbraco 中将显示日期时间格式从英语更改为波斯语。我在 web.config 中应用了这个设置。但是没有用。(属性选项卡中的日期选择器(发布于和删除于))
<globalization enableClientBasedCulture="true" requestEncoding="UTF-8" responseEncoding="UTF-8" uiCulture="fa" culture="fa"/>
我该怎么做?
我想在支持的 Umbraco 中将显示日期时间格式从英语更改为波斯语。我在 web.config 中应用了这个设置。但是没有用。(属性选项卡中的日期选择器(发布于和删除于))
<globalization enableClientBasedCulture="true" requestEncoding="UTF-8" responseEncoding="UTF-8" uiCulture="fa" culture="fa"/>
我该怎么做?
日期格式并没有根据我使用的语言而改变。
我在 umbraco_client\DateTimePicker\umbDateTimePicker.js 中看到硬编码的日期格式根据需要更改然后更新客户端依赖项:
我还在 umbraco.controls 中看到硬编码的日期时间格式字符串:umbraco.uicontrols.DatePicker.DateTimePicker.DateTime setter。
在各种 Umbraco 4.x 版本上完成。
Umbraco 后端中的语言由登录的用户决定。截至目前,Umbraco 仅支持以下开箱即用的语言:
根据为该特定用户选择的语言,日期将以适合该文化的格式显示。
这个论坛帖子,波斯语和 rtl 支持....,提供了一些关于如何添加新翻译的信息,如果你感兴趣的话。
As i search, unfortunately umbraco does not support Persian
date time forma but you can study FormatDateTime and change the appearance to format like yyyy/mm/dd
but for full name of months like فروردین
اردیبهشت
you should create your own control or use other staff like PersianDate® (PD)
In case of code to develop a custom control you can study PersianCalendar Class
and this tiny solution :^)
if your date is a Gregorian date then First you must convert it to Jalali date like this:
PersianCalendar jc = new PersianCalendar();
DateTime date = new DateTime(jc.GetYear(d), jc.GetMonth(d), jc.GetDayOfMonth(d));
string print = string.Format("{0:0000}/{1:00}/{2:00}", date.Year, date.Month, date.Day);
but if your date is a Jalali date already then just use:
string print = string.Format("{0:0000}/{1:00}/{2:00}", date.Year, date.Month, date.Day);
now if you have a string contains a Jalali date like "1390/12/10" and you want to get its day name it ll be a bit tricky.
public static string GetDayOfWeekName(this DateTime date)
{
PersianCalendar jc = new PersianCalendar();
DateTime d = jc.ToDateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0, PersianCalendar.PersianEra);
switch (d.DayOfWeek)
{
case DayOfWeek.Saturday: return "شنبه";
case DayOfWeek.Sunday: return "يکشنبه";
case DayOfWeek.Monday: return "دوشنبه";
case DayOfWeek.Tuesday: return "سه شنبه";
case DayOfWeek.Wednesday: return "چهارشنبه";
case DayOfWeek.Thursday: return "پنجشنبه";
case DayOfWeek.Friday: return "جمعه";
default: return "";
}
First you Should convert it to Gregorian Date then get the Day Name. but not for Months name:
public static string GetMonthName(this DateTime date)
{
switch (date.Month)
{
case 1: return "فررودين";
case 2: return "ارديبهشت";
case 3: return "خرداد";
case 4: return "تير";
case 5: return "مرداد";
case 6: return "شهريور";
case 7: return "مهر";
case 8: return "آبان";
case 9: return "آذر";
case 10: return "دي";
case 11: return "بهمن";
case 12: return "اسفند";
default: return "";
}
}
i would be appreciated if i could provide you more useful post and please let me know it!