> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MicrosoftGame.config 當地語系化

> MicrosoftGame.config 當地語系化

本主題說明如何將封裝遊戲的顯示字串當地語系化，讓殼層中顯示適當的當地語系化字串版本。這些步驟與 Microsoft Docs 上的[在舊版應用程式或遊戲中使用 Windows 10 資源管理系統](https://learn.microsoft.com/windows/uwp/app-resources/using-mrt-for-converted-desktop-apps-and-games)一文相關。如果本主題未涵蓋某些詳細資料或案例，您可能需要參考該文章。

<Note>[先前提及的文章](https://learn.microsoft.com/windows/uwp/app-resources/using-mrt-for-converted-desktop-apps-and-games)中描述了一個錯誤，其中資訊清單檔案內的字串資產是以如下方式參考：</Note>

```
    ms-resource:Resources/ApplicationDisplayName  
```

<Note>實際有效的參考方式如下 (請注意省略了 `Resources/`)：</Note>

```
    ms-resource:ApplicationDisplayName  
```

## 在遊戲中加入當地語系化的殼層視覺效果

開始封裝時，您會有一個 *MicrosoftGame.config* 檔案，其中包含如下的區段，這些區段透過屬性指定要顯示的文字內容：
`OverrideDisplayName="My Game's Display Name"`。

```xml theme={null}

  <ExecutableList>
    <Executable Name="MyGame.exe"
                OverrideDisplayName="My Game's Display Name"
                Id="Game"/>
  </ExecutableList>

  <ShellVisuals DefaultDisplayName="PackageName"
                PublisherDisplayName="Publisher Display name"
                StoreLogo="Storelogo.png"
                Square150x150Logo="Logo.png"
                Square44x44Logo="SmallLogo.png"
                Description="My App Description"
                BackgroundColor="#000040"
                SplashScreenImage="SplashScreen.png"/>  
```

如果您想允許這些字串有不同的當地語系化版本，可以在應用程式中與您要支援之語言相關聯的個別子資料夾內建立 .resw 檔案。

1. 建立名為 *resources.resw* 的 XML 檔案，並將其放在專案的 *Strings* 子資料夾中。這將是專案的語言中性後援。
2. 針對每種語言，為專案建立新的 *Strings* 子資料夾。例如，英文為 *Strings\en-us*，墨西哥使用的西班牙文為 *Strings\es-mx*。請務必針對每種語言使用適當的 [BCP-47](https://tools.ietf.org/html/bcp47) 代碼。
3. 在每個 XML 檔案中加入下列內容，並以適用於您應用程式且使用適當語言的文字取代醒目提示的文字。下列範例示範使用 `(English)` 作為簡單的尾碼。

```xml theme={null}
    <?xml version="1.0" encoding="utf-8"?>
    <root>
        <data name="ApplicationDescription">
            <value>Contoso Demo app with localized resources (English)</value>
        </data>
        <data name="ApplicationDisplayName">
            <value>Contoso Demo Sample (English)</value>
        </data>
    </root>
```

接著，您應該更新 *MicrosoftGame.config* 檔案，使用 `ms-resource:ResourceStringName` 語法參考這些資源字串，如下列 `OverrideDisplayName` 和 `Description` 屬性中所示。

```xml theme={null}
<ExecutableList>
    <Executable Name="MyGame.exe"
              OverrideDisplayName="ms-resource:ApplicationDisplayName"
              Id="Game"/>
</ExecutableList>

<ShellVisuals DefaultDisplayName="PackageName"
              PublisherDisplayName="Publisher Display name"
              StoreLogo="Storelogo.png"
              Square150x150Logo="Logo.png"
              Square44x44Logo="SmallLogo.png"
              Description="ms-resource:ApplicationDescription"
              BackgroundColor="#000040"
              SplashScreenImage="SplashScreen.png"/>
```

接著，請確定您的 *MicrosoftGame.config* 檔案包含應用程式所支援的當地語系化目標清單。例如，如果您的應用程式支援美國英文和墨西哥西班牙文，您的 .config 檔案會將下列內容作為 `Game` 的子元素。

```xml theme={null}
<Resources>
    <Resource Language="en-US" />
    <Resource Language="es-MX" />
</Resources>
```

接著，使用 [makepkg localize](/zh-TW/build/core-features/common/packaging/deployment/makepkg) 命令產生 *Resource.pri* 檔案，其中會包含這些當地語系化的資產字串。將產生的 *Resources.pri* 檔案放在遊戲的根內容目錄中。

1. 在遊戲的根內容目錄中開啟 Microsoft Game Development Kit (GDK) 遊戲命令提示字元。
2. 執行下列命令：

```
    makepkg localize /d . /resw Strings
```

如果您的目錄結構與此範例不符，或需要額外驗證，可以使用其他參數執行 `makepkg localize`。

* 使用 `/resw` 指定相對於根目錄的路徑，以尋找 .resw 檔案。
* 使用 `/pd` 搭配目錄，將產生的 *Resources.pri* 檔案儲存在預設根目錄以外的位置。目標目錄必須已存在。
* 使用 `/t` 搭配目錄名稱，指定將資源匯出至 XML 檔案的位置，您可以手動驗證該檔案以確保其包含適當的資源。

例如：

```
    makepkg localize /d . /resw Resources /pd ..\FinalLooseFolder /t ..\TempOutput
```

現在遊戲的根內容目錄中已有 *resources.pri* 檔案，您可以照常建立套件。

最後，請在系統設定為英文或墨西哥西班牙文的情況下進行安裝，驗證您的當地語系化字串是否顯示在 \[開始] 功能表及其他顯示應用程式字串的系統頁面中。請注意，Microsoft Store 應用程式中的圖示來源是已上傳至 Partner Center 的資料，而不是應用程式套件中的資訊。

## 另請參閱

[MicrosoftGame.config](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-toc)
[MicrosoftGame.config 概觀](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Overview)
[MicrosoftGame.config 編輯器](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Editor)
[MicrosoftGame.config 參考 (範例 MicrosoftGame.config 與結構描述)](/zh-TW/reference/system/microsoftgameconfig/microsoftgameconfig-schema)
[封裝概觀](/zh-TW/build/core-features/common/packaging/overviews/packaging)


## Related topics

- [術語](/zh-TW/publishing/certification/console-cert-terminology.md)
- [XBOX 遊戲的 XBOX 需求](/zh-TW/publishing/certification/xbox-requirements.md)
- [XR-003 提交的遊戲品質](/zh-TW/publishing/certification/xr/xr-003.md)
- [XBOX 主機遊戲的認證測試 XBOX 需求](/zh-TW/publishing/certification/console-cert-tested-requirements.md)
- [認證主機 BVT 指南](/zh-TW/publishing/game-publishing/concepts/certification/certification-console-bvt-guide.md)
