Implementing custom cultures, CultureInfo, localize Azure App Service

You cannot, at this moment, create a custom culture on an Azure App Service.  Cultures are part of the standard operating system and require changes to the registry to modify or add them.  An Azure App Service runs in a sandbox which does not allow code or script to modify the registry.  I do not work on the team responsible for this Windows feature, but I have confidence the team puts lots of diligence into providing the fundamental capabilities to match the requirements of most global cultures.

Here is a dump of all the cultures on an Azure App Service and here is the source code I used to do that.

When I get asked about custom cultures I am often confronted with these 2 misconceptions:

  • Do you need a Custom Culture or are you really looking for localization
  • Implementing a Custom Culture is assumed to be a translation service

The need to create a custom culture implies that one of the existing cultures does not specifically meet the the needs of your implementation.  This can happen.  With many sub cultures, dialects and small communities there are certainly subtle differences which a member of those entities would like to include into their application to make it target the consumer in a more precise manner.  Here is some information you can use to create a custom culture, notice that it writes to the registry, so you cannot run that code on an Azure App Service.

A culture, by default include things like Number, Currency, Time and Date formats, as shown in Figure 1.

image

Figure 1, creating custom cultures on an Azure App Service

That is it.  Anything beyond those cultural formats and you are looking in the wrong place.  The concept you are actually looking for is referred to as localization.  A custom culture will not translate textbox labels or messages rendered in your application.  Nor will it translate any of the content on your site.

You will need to do that yourself using .resx files, where you provide the translated labels or messages then reference them based on the selected culture in the client.  I wrote some articles about doing this here and here (for ASP.NET).  It is not overly complex but it does require some time, effort and testing.

There is some support for language packs on IIS which I write about here.  In this case, you need to install a language pack for the language you want to respond in and the language pack does include the translated version of the IIS errors.  But, you cannot install language packs on an Azure App Service platform yourself.  To find which language packs are on an Azure App Service instance, you can access KUDU/SCM and dup the contents of the D:\inetpub\custerr directory.