asp.net mvc 4 - Apply regional settings to application based on user profile -


i have mvc 4 application international users (all on world). want add new page called profile settings users can select regional settings , mean should able select:

  - time zone      (utc +- .....)   - date format    (dd.mm.yyyy or dd/mm/yyyy or mm/dd/yyyy ....)   - time format    (12/24 - pm)   - number format  (1234.56 or 1234,56) 

after user selects regional settings, specific data (date, time, number ...) should shown in specific format.

any advice how make work?

most of time, shouldn't expose each , every detail of culture format users. instead, provide drop-down list of cultures want support. cultures specified using codes. common codes en-us (english/usa), es-mx (spanish/mexico) , de-de (germany/german). first part refers language, , second part refers specific country or region.

once have selected culture code, can apply each user, such as:

cultureinfo culture = new cultureinfo("en-us"); thread.currentthread.currentculture = culture; 

if using culture-specific resource files, need:

thread.currentthread.currentuiculture = culture; 

there several places this, common location in application_beginrequest event in global.asax file.

there tutorial on msdn here.

while common think time zones when considering regional settings, quite different things , should considered separately. time zones can't set globally, need consider how affect application logic in each , every place work date , time. should timezoneinfo class. if have questions, please ask separately. although if search, may find many have been answered.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -