Formatting numerals and dates in other locales in C#/.NET -
in application i'm writing want display current date , time, in english, in other locales.
for example russian, arabic , chinese.
// datetime.tolongdatestring doesn't support iformatprovider parameter datetime.now.tostring("dddd, d mmmm, yyyy", new cultureinfo("en-us")); // "wednesday, 7 august, 2013" datetime.now.tostring("dddd, d mmmm, yyyy 'r.'", new cultureinfo("ru-ru")); // "среда, 7 августа, 2013 r."
works fine...
datetime.now.tostring("dddd٫ d mmm٫ yyyy", new cultureinfo("ar")); // "الأربعاء٬ 30 رمضان٬ 1434"
seems work fine.
however... i'd show numerals (eastern) arabic numerals, not latin/arabic numerals. though of course solved doing simple substitution ('٠' '0', 1 '١' etc).
but there's chinese:
datetime.now.tostring("yyyy年m月d日dddd", new cultureinfo("zh-cn")) // "2013年8月7日星期三"
chinese numerals seem quite bit more complex doing simple substitution; 1 character becomes 2. next that, formatted date seems show current gregorian date, not current chinese date.
so question is:
a) there localization functionality in .net/c# display numbers (specificly dates) in other numeralsystems?
b) can force .net/c# display dates in chinese (and possibly japanese , other) calendars, seems arabic calendar?
see these questions (and answers):
how can display culture-specific native digits instead of arabic numerals?
msdn: http://msdn.microsoft.com/en-us/library/system.globalization.digitshapes.aspx
as whether work all languages? ...i wouldn't bet on it, in cultures of china there multiple ways , context-sensitive usage.
Comments
Post a Comment