Skip to content

thurstonford/Localize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Localize

IIS module that enables granular control of culture-specific formats via the config file.

By default, ASP.NET only supports globalization in the web.config file, ie: forcing the application to a specific culture eg: en-US, en-FR, en-RU etc. The application then uses the regional settings of the host for displaying currency, number and date time information. Issues can arise with how currency, number and date/time information is handled if these regional settings differ between hosts (eg: migrating sites/services from one server to another). This IIS module allows the developer to override the format of the individual NumberFormatInfo and DateTimeFormatInfo properties in the web.config file.

Features

  • Granular control of currency, number and date/time formats for multiple cultures.
  • Global override (apply speciifc format regardless of culture).
  • Multi-process support (worker threads also honour your specified formats).
  • Override values of all public properties of the NumberFormatInfo and DateTimeFormatInfo objects.
  • No code changes required - all controlled via the web.config file.

Getting Started

Add the Localize.dll file to the bin directory of your ASP.NET web application or web service. Add config (see below). Test. Smile.

Add Config

Register the module with IIS via your web.config file:

<!-- Required -->
<system.webServer>
    <modules>
        <add name="Localize" type="Localize.CultureHelper" />            
    </modules>        
</system.webServer>

Override the hosts regional settings with custom values defined in your web.config file, eg:

<!-- Force a specific culture (optional) -->
<add key="culture.cultureName" value="en-FR" />

<!-- Global override -->
<add key="culture..NumberDecimalSeparator" value="!" />
<add key="culture..NumberGroupSizes" value="2,3,2" />
<add key="culture..CurrencySymbol" value="Z" />

<!-- Override culture-specific settings (optional, case-insensitive) -->
<add key="culture.en-za.NumberDecimalSeparator" value="." />
<add key="culture.en-za.numberdecimalDigits" value="99" />
<add key="culture.en-za.currencySymbol" value="#" />
<add key="culture.en-za.ShortDatePattern" value="MM-dd-yyyy" />
<add key="culture.en-za.ShortTimePattern" value="HHmm" />
<add key="culture.en-za.MonthDayPattern" value="MMM d" />

<add key="culture.en-US.currencySymbol" value="#" />

<add key="culture.en-fr.currencySymbol" value="@" />

Logging:

Exceptions are handled gracefully and logged to the Windows Event Log.

Additional documentation

Feedback

I welcome comments, suggestions, feature requests and honest criticism :)

Want to show your appreciation?

That's mighty generous - thank you!
Buy me a coffee

About

IIS module that enables granular control of culture-specific formats via the config file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages