Internationalizing A C# Windows Form Game

Introduction

In order to explore using resource files to localize, I found a completely un-internationalized game written in C# and set out to internationalize it. The game is a simplistic top-down racing game created within a Windows Form and was originally written by MOO ICT as a C# tutorial. šThree different images display based on the player’s score results, and the “Start” button restarts the game. There are also fields to show the game instructions and the current score.

šAn initial internationalization analysis shows that some text is in the code, some is embedded within the Windows form design, and the images are only available in English. This means that several methods of localization will be required to produce a fully internationalized product.

Methods of Localization For Text and Images

Two primary methods of localization were required; one for the text string and image resources called in the form’s code, and one for the text strings that were embedded in text boxes or labels within the Windows form. The former were localized using resource files, and the latter used the Localizable property built into the Windows form.

Challenges

There were two major challenges that I encountered while internationalizing the game. The first was installing the capability to switch languages within the application, and the second was a bug specific to the start button. While I was able to come up with a working solution to the language switching issue, the start button bug was only resolved when I entirely rewrote the program from scratch, so it is unclear what the issue was.

Language Switching Capability

When I was testing the game in different locales, I manually changed the CurrentUICulture for each test. Since this method required a full restart of the app, it was obviously an inefficient and annoying way of accessing the localized versions, so a new method was necessary.

I attempted several solutions, including using a dropdown menu or radio buttons, doing a soft restart and load into a different CurrentUICulture with Application.Restart(), resetting the game with a different ISO code within the app, and assigning the CurrentUICulture using the Component Resource Manager. Unfortunately, none of these methods were successful.

In the end, I created another project to add to the Visual Studio solution I was working in. This project, named Language Launcher, is a simple Windows Form with buttons for each supported locale. Clicking the buttons assigns the correct ISO code to the CurrentUICulture attribute, and then calling the original game project. I set the Language Launcher project as the Startup Project for the solution, so the game would always be run through the new project with assigned ISO values.

Start Button Migration Bug

The first language I localized the program into was Japanese. When testing it, I noticed that the start button in the localized version would migrate across the app, sometimes resulting in the button being almost completely cut off and out of sight. The bug details are as follows:

  • While it originally appeared that the bug appeared when a localized file was loaded, when French support was added, the bug was not present
  • šThe bug only appeared in Japanese, meaning that it was likely caused by a problem with the different character encoding
  • šFont, text size, padding, and margin were all manipulated with no success
  • Cleaning the build also had no effect
  • šDeleting the original start button and rebuilding it did not solve the bug

As there were some other bugs I was unsure of how to solve, it became clear that downloading a clean copy of the game and rebuilding all the internationalization features I had created would be a better solution than trying to puzzle out how to solve the errors. Once the application had been rebuilt, the start button migration was no longer an issue.

Results

The game was successfully localized into 5 languages: English, Japanese, Russian, Spanish, and French. This includes localizing the 3 reward images that appear. These images were added and called through the locale-specific resource files. The game is also fully internationalized, meaning that support for any other language could be added within a matter of minutes. After thorough testing to make sure the game was playable and displayed well in every locale, I added some creative embellishments. The overall results can be seen below.

Thanks to the Translation and Localization Management professors at MIIS for being very tolerant of my blatant misuse of their faces.