How to localize the title of a Windows Phone game created with XNA Game Studio 4.0
Note - there is now a simpler set of steps to create a game with a localized title, and I have written a newer blog post with updated steps. Please refer to https://blogs.msdn.com/b/astebner/archive/2010/12/10/10103522.aspx for more details.
Recently, a user posted a question on the XNA forums asking how to localize the name of their Windows Phone game. They were attempting to follow the How to: Localize an Application Title for Windows Phone tutorial in the Windows Phone documentation, but were running into some issues. That tutorial contains instructions for localizing the title of a Silverlight application, but the steps are a bit different for XNA games. I also found some of the steps to be vague and/or confusing while I tried to work through them on my own.
I’ve created an updated set of steps that can be used to localize the name of a Windows Phone game created with XNA Game Studio 4.0. I also uploaded a sample solution that implements these steps.
The steps below and the sample solution that I have created both require that you use Visual Studio 2010 Professional, Premium or Ultimate because the steps require a version of Visual Studio that supports creating a solution that contains both C++ and C# projects. The VS 2010 Express Editions do not support this.
Step 0 – Create a Windows Phone game project
- Start Visual Studio 2010.
- Click on File | New | Project..., select Visual C# | XNA Game Studio 4.0 and choose Windows Phone Game (4.0).
Step 1 – Create a language-neutral native resource DLL
Note - the name of the native resource DLL is important in this scenario. It must be named AppResLib.dll, and the localized versions must be named AppResLib.dll.*.mui. If they are named differently, your game will be rejected by the Windows Phone Marketplace certification process.
Right-click on the solution that contains your Windows Phone Game project and choose Add | New Project...
Select Visual C++ | Win32 | Win32 Project and name it AppResLib.
In the Win32 Application Wizard, select DLL and check the Empty Project check box, then click Finish.
Right-click on the AppResLib project in the Visual Studio solution explorer and choose Properties.
Change the Configuration drop-down from Active (Debug) to All Configurations.
Expand Configuration Options | Linker and click on Advanced.
Set the No Entry Point value to Yes (/NOENTRY) and click OK.
Right-click on the AppResLib project in the Visual Studio solution explorer and choose Add | Resource...
Click on String Table and then click New.
Add two strings to the string table with the following IDs:
AppTitle
AppTileStringSet the AppTitle value to 100 and set the caption to the language-neutral name of your game that will be displayed in the Games Hub or the Application List.
Set the AppTileString value to 200 and set the caption to the language-neutral name of your game that will be displayed when the game is pinned to the Windows Phone start menu.
Build the AppResLib project.
Step 2 – Create an English (US) native resource DLL
Right-click on the solution that contains your Windows Phone Game project and choose Add | New Project...
Select Visual C++ | Win32 | Win32 Project and name it AppRes0409.
In the Win32 Application Wizard, select DLL and check the Empty Project check box, then click Finish.
Right-click on the AppRes0409 project in the Visual Studio solution explorer and choose Properties.
Change the Configuration drop-down from Active (Debug) to All Configurations.
Expand Configuration Options | Linker and click on Advanced.
Set the No Entry Point value to Yes (/NOENTRY) .
Expand Configuration Options | Resources and click on General.
Set the Culture value to English (United States) (0x409) (/l 0x0409) .
Expand Configuration Options | Build Events and click on Post-Build Event.
Set the Command Line value to the following:
copy "$(OutputPath)$(ProjectName).dll" "$(OutputPath)\AppResLib.dll.0409.mui"
Right-click on the AppRes0409 project in the Visual Studio solution explorer and choose Add | Resource...
Click on String Table and then click New.
Add two strings to the string table with the following IDs:
AppTitle
AppTileStringSet the AppTitle value to 100 and set the caption to the English (United States) name of your game that will be displayed in the Games Hub or the Application List.
Set the AppTileString value to 200 and set the caption to the English (United States) name of your game that will be displayed when the game is pinned to the Windows Phone start menu.
Build the AppRes0409 project.
Step 3 – Create native resource DLLs for other supported languages
- Repeat Step 2 and create the resource-only DLL for English (United Kingdom). Set the Resource Culture to English (United Kingdom) (0x809) (/l 0x0809) and update the post-build event command line to rename the DLL file to AppResLib.dll.0809.mui.
- Repeat Step 2 and create the resource-only DLL for French (France). Set the Resource Culture to French (France) (0x40c) (/l 0x040c) and update the post-build event command line to rename the DLL file to AppResLib.dll.040c.mui.
- Repeat Step 2 and create the resource-only DLL for Italian (Italy). Set the Resource Culture to Italian (Italy) (0x410) (/l 0x0410) and update the post-build event command line to rename the DLL file to AppResLib.dll.0410.mui.
- Repeat Step 2 and create the resource-only DLL for German (Germany). Set the Resource Culture to German (Germany) (0x407) (/l 0x0407) and update the post-build event command line to rename the DLL file to AppResLib.dll.0407.mui.
- Repeat Step 2 and create the resource-only DLL for Spanish (Spain). Set the Resource Culture to Spanish (Spain) (0xc0a) (/l 0x0c0a) and update the post-build event command line to rename the DLL file to AppResLib.dll.0c0a.mui.
Step 4 – Add native resource DLLs to your Windows Phone game project
- Right-click on your Windows Phone game project in the Visual Studio solution explorer, click Add | Existing Item...
- Browse to the file named AppResLib.dll that you built in step 2 above, click the down arrow next to the Add button, and then select Add as Link.
- Browse to each of the files named AppResLib.dll.*.mui that you built in steps 3 and 4 above, click the down arrow next to the Add button, and then select Add as Link.
- For each of the AppResLib.dll* files added as links, set the Build Action property to None and the Copy to Output Directory property to Copy if newer. This will make sure that each of these files gets packaged into the XAP file that is created when you build your Windows Phone Game project.
Step 5 – Make your Windows Phone game project dependent on the native resource DLL projects
- Right-click on the solution that contains your Windows Phone Game project and your resource DLL projects in the Visual Studio solution explorer and choose Project Dependencies...
- Select your Windows Phone Game project in the Projects drop-down.
- Check all of the check boxes next to your resource DLL projects and click OK.
Step 6 – Update your Windows Phone game to load title strings from the resource DLLs
Update the application title by doing the following:
In your Windows Phone Game project, open the file Properties\AssemblyInfo.cs.
Remove the AssemblyTitle entry.
Add an AssemblyTitleAttribute entry that looks like this:
[assembly: AssemblyTitleAttribute("@AppResLib.dll,-100")]
Update the tile title by doing the following:
Right-click on your Windows Phone Game project in the Visual Studio solution explorer and choose Properties.
Click on the XNA Game Studio tab.
Change the Tile title value to look like this:
@AppResLib.dll,-200
The tile title is the name that is displayed if you click and hold on your application/game in the Windows Phone OS and choose to pin it to the start menu. There is some additional information about these properties and how to configure them in XNA Game Studio games in this documentation topic. Depending on the scenarios you want to support for your game, it may not be necessary to create separate strings for your application title and tile title. If you plan to use the same string for both, you do not need to create separate entries in the string table in each of your native resource DLLs in the instructions above.
Step 7 – Rebuild your Windows Phone game solution
Rebuild the solution that contains your Windows Phone Game project and your resource DLL projects. When doing so, make sure that the Windows Phone Game project is set as the startup project (as opposed to one of the resource DLL projects or your content project).
<update date="10/15/2010"> I found out today that the ingestion process requires that the resource DLL be named AppResLib.dll, so I've updated the steps in this post to reflect that, and I've posted an updated sample solution. </update>
<update date="1/18/2011"> Added a stronger warning about the naming of the DLL needing to exactly match what is listed in the documentation. </update>