> ## 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、區塊配置與 Intelligent Delivery 將 GDK 套件中的字串、影像與資產當地語系化,以進行各地區設定的下載。

`MicrosoftGame.config` 中參考的字串與影像,可以當地語系化為使用者的地區設定。Visual Studio 2019+ 會自動產生 `resources.pri` 檔案,供作業系統在執行階段查閱。

從 GDK 命令提示字元傾印該檔案:

```text theme={null}
MakePri.exe dump /if resources.pri /of out.xml
```

## 將應用程式名稱與描述當地語系化

### 新增預設字串

1. 在方案總管中以滑鼠右鍵按一下您的專案,並新增名為 `Strings` 的**新增篩選**。
2. 以滑鼠右鍵按一下 `Strings`,並新增**新增項目 > 組件資源檔 (.resx)**。VS 會在套件根目錄建立 `resources.resx`。

<Note>
  GDK 需要 `.resw`。請將 `resources.resx` 重新命名為 `resources.resw`。
</Note>

### 在 MicrosoftGame.config 中參考字串

```xml theme={null}
<ShellVisuals DefaultDisplayName="ms-resource:AppName"
              PublisherDisplayName="Publisher Display name"
              StoreLogo="StoreLogo.png"
              Square150x150Logo="Logo.png"
              Square44x44Logo="SmallLogo.png"
              Description="ms-resource:AppDescription"
              BackgroundColor="#000040"
              SplashScreenImage="SplashScreen.png"/>
```

### 新增各語言的字串

為每種支援的語言建立 `Strings/<lang>` 篩選,在每個篩選下新增組件資源檔,將**項目類型**設為 **PRI 資源**,並重新命名為 `.resw`。

### 在 MicrosoftGame.config 中宣告語言

```xml theme={null}
<Resources>
    <Resource Language="en-US"/>
    <Resource Language="fr-FR"/>
    <Resource Language="de-DE"/>
</Resources>
```

若要支援繁體中文,也請列出 `zh-SG` 與 `zh-CN` 作為後援。

## 將影像當地語系化

`Logo`、`SmallLogo`、`SplashScreen`、`StoreLogo` 可以當地語系化:

1. 在共用資料夾 (例如 `Images`) 下新增各語言的子資料夾。
2. 新增影像,並將**項目類型**設為**影像**、**內容**設為**是**。
3. 在根目錄提供預設影像作為後援。

<Note>
  請至少包含一個影像資源。否則當地語系化的字串將無法解析,遊戲名稱會顯示為 `ms-resource:AppName`。
</Note>

## 區塊配置

```xml theme={null}
<Chunk Id="1000" Marker="Launch">
    <FileGroup DestinationPath="\Images"       SourcePath="Images"       Include="*.*"/>
    <FileGroup DestinationPath="\Images\en-US" SourcePath="Images\en-US" Include="*.*"/>
    <FileGroup DestinationPath="\Images\fr-FR" SourcePath="Images\fr-FR" Include="*.*"/>
    <FileGroup DestinationPath="\" SourcePath="." Include="resources.pri"/>
</Chunk>
```

## Intelligent Delivery

使用 `Languages` 標記區塊:

```xml theme={null}
<Chunk Id="1005" Languages="en-US">
    <FileGroup DestinationPath="\assets\audio" SourcePath="." Include="en_us_commentary.mp3"/>
</Chunk>
<Chunk Id="1008" Languages="es-MX, en-US">
    <FileGroup DestinationPath="\assets" SourcePath="." Include="mixed_content.dat"/>
</Chunk>
```

### 安裝行為

* 主機為 `en-US` → 安裝 1005 與 1008。
* 主機為 `en-GB` → 後援為 `en-US` → 安裝 1005 與 1008。
* 未標記的區塊一律會安裝。

### 使用 xbapp 進行測試

* `/Languages`:無論主機設定為何,都針對列出的語言進行安裝。
* `/AllChunks`:安裝整個套件。
* `/w`:安裝後保持連線開啟。

## 另請參閱

* [MicrosoftGame.config 當地語系化](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Localization)
* [Intelligent Delivery](/zh-TW/build/core-features/common/packaging/intelligentdelivery-features-recipes)

## 相關 API 文件

* [XPackage API 參考](/zh-TW/reference/system/xpackage/xpackage_members):掛接/列舉當地語系化的套件區塊
* [MicrosoftGame.config 元素參考](/zh-TW/reference/system/microsoftgameconfig/elements/gc-microsoftgameconfig-toc):資源 + 區塊宣告


## Related topics

- [Economy v2 當地語系化](/zh-TW/services/playfab/economy-monetization/economy-v2/catalog/localization.md)
- [支援的語言](/zh-TW/publishing/game-publishing/concepts/metadata-supported-languages.md)
- [搭配 Unity 使用 GDK](/zh-TW/build/gdk-and-engines/unity/unity.md)
- [MicrosoftGame.config 當地語系化](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Localization.md)
- [當地語系化與全球化概觀](/zh-TW/build/game-principles/localization.md)
