OK, I can not install mentioned package in a shared host.
My solution is to call a static method to fix it:
http://www.codeproject.com/Articles/250740/Fixing-Optional-Calendars-for-Persian-Culture-in-NBut where can I use "FixAndSetCurrentCulture()" method based on mentioned article every time the content Culture and UI Culture change to "fa-ir"?
Can I change Culture of whole Kentico CMS based on these two lines code and where:
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;/// <summary>
/// Set the CurrentCulture of current thread to a new fixed Persian culture.
/// </summary>
/// <returns>The fixed Persian cultreinfo.</returns>
public static CultureInfo FixAndSetCurrentCulture()
{
CultureInfo culture = FixPersianCulture(null,FixCultureOptions.foptAll);
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
return culture;
}
/// <summary>
/// Fixes CultureInfo for Persian resources (months and day names) and also PersianCalendar.
/// </summary>
/// <param name="culture">The CultureInfo instace to be fixed. If NULL, a new instance will be created and returned.</param>
/// <param name="options">Specifies what to be fixed.</param>
/// <returns>A new instance of fixed Persian CultureInfo.</returns>
public static CultureInfo FixPersianCulture(CultureInfo culture, FixCultureOptions options)
{
PropertyInfo calendarID = typeof(Calendar).GetProperty("ID", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo cultureInfoReadOnly = typeof(CultureInfo).GetField("m_isReadOnly", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
FieldInfo cultureInfoCalendar = typeof(CultureInfo).GetField("calendar", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
//FieldInfo cultureInfoReadOnly = typeof(CultureInfo).GetField("m_", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
if (culture == null)
culture = new CultureInfo("fa-IR", false);
if (culture == null || culture.LCID != 1065)
return culture;
if ((options & FixCultureOptions.foptAll) == FixCultureOptions.foptAll)
options = FixCultureOptions.foptCalendarInCulture | FixCultureOptions.foptCalendarInDateFormatInfo |
FixCultureOptions.foptOptionalCalendars;
if ((options & FixCultureOptions.foptOptionalCalendars) == FixCultureOptions.foptOptionalCalendars)
{
FixOptionalCalendars(culture, 4);
culture = new CultureInfo("fa-IR", false);
}
bool readOnly = (bool)cultureInfoReadOnly.GetValue(culture);
if (readOnly)
{
cultureInfoReadOnly.SetValue(culture, false);
}
if ((options & FixCultureOptions.foptCalendarInDateFormatInfo) == FixCultureOptions.foptCalendarInDateFormatInfo)
culture.DateTimeFormat = FixPersianDateTimeFormat(culture.DateTimeFormat, true);
else
FixPersianDateTimeFormat(culture.DateTimeFormat, false);
if ((options & FixCultureOptions.foptCalendarInCulture )
== FixCultureOptions.foptCalendarInCulture)
{
cultureInfoCalendar.SetValue(culture, new PersianCalendar());
}
if (readOnly)
{
cultureInfoReadOnly.SetValue(culture, true);
}
return culture;
}