Register custom culture in Windows Azure

情到浓时终转凉″ 提交于 2020-01-01 13:33:41

问题


I am currently developing an ASP.NET MVC 4 app for the African market and was hoping to register a custom culture using the steps detailed in the following link http://msdn.microsoft.com/en-gb/library/system.globalization.cultureandregioninfobuilder.register(v=vs.110).aspx. Most of my target countries are not in the pre-installed cultures so it sounds like I need to register these cultures. Problem is, my console app for doing the registration will need admin previlidges to complete the culture registration. I am presuming windows azure does not allow developers admin control of the cloud service environment.

Question: What is the best way to register a custom culture in Windows Azure without admin previlidges. Apparently there's a way to do this on Framework 2.0 using the cultureandregioninfobuilder.compile method but this is not a supported method. Is there a better solution? Don't want to have to maintain different project solutions for each culture just so I can support different languages.

Thanks in advance.


回答1:


You could create a startup task that runs with elevated priviledges, and also run your application on a limited context. Your service configuration file should look like this:

 <ServiceDefinition name="MyCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-10.1.8">
  <WebRole name="MyWebRole" vmsize="Small">
    <Runtime executionContext="limited">
    </Runtime>
    <Startup>
      <Task executionContext="elevated" commandLine="scripts\SetupCulture.cmd" taskType="simple">
        <Environment>
          <Variable name="CULTURE">
            <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='Culture']/@value" />
          </Variable>
        </Environment>
      </Task>
    </Startup>
    ...

   </WebRole>
 </ServiceDefinition>

Note with this you can specify the desired culture in the service configuration file. Finally you can use the environment variable "CULTURE" in your .cmd file to use it as parameter to a .NET executable doing the job.




回答2:


I have used approach described by David - running script with elevated admin privileges.

In order to create custom culture, I have used this article How to: Save Custom Cultures Without Administrative Privileges.

Code still requires admin rights even though it says the opposite, but it works when executed as described above.

Proved to be working for Sitecore project in Azure.



来源:https://stackoverflow.com/questions/14955959/register-custom-culture-in-windows-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!