<i id='FYnBU'><tr id='FYnBU'><dt id='FYnBU'><q id='FYnBU'><span id='FYnBU'><b id='FYnBU'><form id='FYnBU'><ins id='FYnBU'></ins><ul id='FYnBU'></ul><sub id='FYnBU'></sub></form><legend id='FYnBU'></legend><bdo id='FYnBU'><pre id='FYnBU'><center id='FYnBU'></center></pre></bdo></b><th id='FYnBU'></th></span></q></dt></tr></i><div id='FYnBU'><tfoot id='FYnBU'></tfoot><dl id='FYnBU'><fieldset id='FYnBU'></fieldset></dl></div>
  • <small id='FYnBU'></small><noframes id='FYnBU'>

      • <bdo id='FYnBU'></bdo><ul id='FYnBU'></ul>
      <legend id='FYnBU'><style id='FYnBU'><dir id='FYnBU'><q id='FYnBU'></q></dir></style></legend>
      1. <tfoot id='FYnBU'></tfoot>

        在 Windows Docker 容器中设置语言和区域设置

        时间:2023-10-06
          <tbody id='JljeO'></tbody>
        <tfoot id='JljeO'></tfoot>

        <small id='JljeO'></small><noframes id='JljeO'>

              <bdo id='JljeO'></bdo><ul id='JljeO'></ul>
              • <i id='JljeO'><tr id='JljeO'><dt id='JljeO'><q id='JljeO'><span id='JljeO'><b id='JljeO'><form id='JljeO'><ins id='JljeO'></ins><ul id='JljeO'></ul><sub id='JljeO'></sub></form><legend id='JljeO'></legend><bdo id='JljeO'><pre id='JljeO'><center id='JljeO'></center></pre></bdo></b><th id='JljeO'></th></span></q></dt></tr></i><div id='JljeO'><tfoot id='JljeO'></tfoot><dl id='JljeO'><fieldset id='JljeO'></fieldset></dl></div>
              • <legend id='JljeO'><style id='JljeO'><dir id='JljeO'><q id='JljeO'></q></dir></style></legend>
                  本文介绍了在 Windows Docker 容器中设置语言和区域设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在创建一个基于 mcr.microsoft.com/dotnet/framework/runtime:4.8 基础映像的 docker 容器.

                  I'm creating a docker container based on the mcr.microsoft.com/dotnet/framework/runtime:4.8 base image.

                  此图像设置为 en_US,这意味着所有 Windows 语言和区域设置以及默认位置都设置为美国.

                  This image is set to en_US, meaning that all the Windows language and region settings and default location is set to United States.

                  我需要做的是将其更改为 en_GB 并将默认用户的位置更改为 United Kindom 因为我有一个具有依赖关系的 .Net 应用程序在使用它来将数据输出到 Excel 的第 3 方库上.但是到目前为止,我尝试过的任何东西似乎都无法更改语言和区域设置.

                  What I need to do is to change this to en_GB and change the location to United Kindom for the default user because I have a .Net application which has a dependency on a 3rd party library that uses this to output data to Excel. However nothing I've tried seems to be able to change the language and region settings thus far.

                  到目前为止我尝试过的事情:

                  Things I have tried so far:

                  1. 尝试使用 intl.cpl 国际设置导入设置并更新默认用户:
                  1. Attempted to use the intl.cpl International Settings to import the settings and update the default user:

                  # Set Locale and language 
                  & $env:SystemRootSystem32control.exe "intl.cpl,,/f:`"UKRegion.xml`""
                  
                  # Set Languages/culture
                  Set-Culture en-GB
                  

                  UKRegion.xml 的内容:

                  Contents of UKRegion.xml:

                  <gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
                      <!--User List-->
                      <gs:UserList>
                          <gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/> 
                      </gs:UserList>
                  
                      <!-- user locale -->
                      <gs:UserLocale> 
                          <gs:Locale Name="en-GB" SetAsCurrent="true"/> 
                      </gs:UserLocale>
                  
                      <!-- system locale -->
                      <gs:SystemLocale Name="en-GB"/>
                      <!-- GeoID -->
                  
                      <gs:LocationPreferences>
                          <gs:GeoID Value="242"/>
                      </gs:LocationPreferences>
                  
                      <gs:MUILanguagePreferences>
                          <gs:MUILanguage Value="en-GB"/>
                          <gs:MUIFallback Value="en-US"/>
                      </gs:MUILanguagePreferences>
                  
                      <!-- input preferences -->
                      <gs:InputPreferences>
                          <!--en-GB-->
                          <gs:InputLanguageID Action="add" ID="0809:00000809" Default="true"/> 
                      </gs:InputPreferences>
                  </gs:GlobalizationServices>
                  

                  1. powershell 脚本中启动应用程序之前设置值:
                  1. Setting the values before starting the application in a powershell script:

                  Set-WinSystemLocale -SystemLocale en-GB
                  Set-WinHomeLocation -GeoId 242
                  Set-WinUserLanguageList -LanguageList (New-WinUserLanguageList -Language en-GB) -Force
                  Set-Location -Path "C:\AppFolder"
                  .AppExe.exe
                  

                  设置容器并附加后,我可以看到 Get-WinHomeLocation 已更新,Get-WinUserLanguageList 显示 en_GB 作为选项,但是,来自 Get-WinSystemLocale 的 Windows 的默认语言仍然返回 en-US

                  After setting up the container and attaching I can see that Get-WinHomeLocation has updated, Get-WinUserLanguageList shows en_GB as an option, however the default language for windows from Get-WinSystemLocale still returns en-US

                  我还考虑过从 en-GB Windows Server Core 基本映像构建自己的基本映像并运行 Microsoft 运行的框架设置以创建 Framework runtime 4.8 映像,但 Microsoft 似乎没有发布 en-GB 基本映像图片!

                  I also considered building my own base image from the en-GB Windows Server Core base image and running the framework setup that Microsoft runs to create the Framework runtime 4.8 image, but Microsoft don't seem to publish an en-GB base image!

                  还有其他人遇到过这个吗?你是怎么解决的?还有其他建议吗?

                  Has anyone else come across this? How did you resolve it? Any other suggestions?

                  推荐答案

                  答案是Docker容器在使用进程隔离时会从宿主机继承语言设置.因此,根据需要更改主机的语言设置.在 PowerShell 中,要设置区域,您可以这样做:

                  The answer is that a Docker container inherits language settings from the host when using Process Isolation. So, change the host's language settings as desired. In PowerShell, to set the Region you can do this:

                  Set-WinSystemLocale en-GB
                  Restart-Computer
                  

                  现在运行 Docker:

                  Now run Docker:

                  docker run -it --isolation=process mcr.microsoft.com/windows/servercore:1909 PowerShell
                  

                  在 Docker 外壳中:

                  Within the Docker shell:

                  Get-WinSystemLocale
                  
                  LCID             Name             DisplayName
                  ----             ----             -----------
                  2057             en-GB            English (United Kingdom)
                  

                  这篇关于在 Windows Docker 容器中设置语言和区域设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:企业库应用程序块还是自研框架? 下一篇:.net runtime 2.0 而不是最新版本?

                  相关文章

                  <legend id='jzqBm'><style id='jzqBm'><dir id='jzqBm'><q id='jzqBm'></q></dir></style></legend>
                  1. <i id='jzqBm'><tr id='jzqBm'><dt id='jzqBm'><q id='jzqBm'><span id='jzqBm'><b id='jzqBm'><form id='jzqBm'><ins id='jzqBm'></ins><ul id='jzqBm'></ul><sub id='jzqBm'></sub></form><legend id='jzqBm'></legend><bdo id='jzqBm'><pre id='jzqBm'><center id='jzqBm'></center></pre></bdo></b><th id='jzqBm'></th></span></q></dt></tr></i><div id='jzqBm'><tfoot id='jzqBm'></tfoot><dl id='jzqBm'><fieldset id='jzqBm'></fieldset></dl></div>

                  2. <tfoot id='jzqBm'></tfoot>

                      <bdo id='jzqBm'></bdo><ul id='jzqBm'></ul>

                      <small id='jzqBm'></small><noframes id='jzqBm'>