Categories
Blog

Game Localization: Localize a Java Game

In the group project for the course Software & Game Localization, our group localizes a Java game called Tetris. In this portfolio, I would like to share with you what we’ve done for this project and the problems we’ve solved.

In the group project for the course Software & Game Localization, our group localizes a Java game called Tetris. In this portfolio, I would like to share with you what we’ve done for this project and the problems we’ve solved.

Externalize strings

The platform we use to localize the game is Eclipse. It can help us to externalize strings in a very convenient way. In the Source panel, we can click “Externalize Strings”, choose the Java file that may contain strings, unclick the strings that we don’t want to translate, and the system will automatically externalize all the strings that appear in the game, and generate a property file and a Messages.Java file.

[ngg_images source=”galleries” container_ids=”4″ display_type=”photocrati-nextgen_basic_thumbnails” override_thumbnail_settings=”0″ thumbnail_width=”240″ thumbnail_height=”160″ thumbnail_crop=”1″ images_per_page=”20″ number_of_columns=”0″ ajax_pagination=”0″ show_all_in_lightbox=”0″ use_imagebrowser_effect=”0″ show_slideshow_link=”1″ slideshow_link_text=”[Show slideshow]” order_by=”sortorder” order_direction=”ASC” returns=”included” maximum_entity_count=”500″]

We think the way how the system wraps the strings isn’t suitable for the internationalization. Therefore, we use the replace function to change the wrapping in bulk. The “Externalize Strings” function still allows us to efficiently find out all the strings that need to be translated in the game.

 

GUI

The original interface of the Tetris game is rather plain.

[ngg_images source=”galleries” container_ids=”5″ display_type=”photocrati-nextgen_basic_thumbnails” override_thumbnail_settings=”0″ thumbnail_width=”240″ thumbnail_height=”160″ thumbnail_crop=”1″ images_per_page=”20″ number_of_columns=”0″ ajax_pagination=”0″ show_all_in_lightbox=”0″ use_imagebrowser_effect=”0″ show_slideshow_link=”1″ slideshow_link_text=”[Show slideshow]” order_by=”sortorder” order_direction=”ASC” returns=”included” maximum_entity_count=”500″]

At first, we plan to add a drop-down language picker or show a sign that users can press a certain button on the keyboard to change the languages. However, since all the members in our team just have a smattering of knowledge about Java, we think it would be very difficult to directly add changes in the original main class.

Therefore, we come up with an idea that we can create another class and write all the code relative to language switcher on it. In this way, when we play the game, we will first see a window for us to choose the language before we enter the game.

Thus, we create another class and name it as LanguagePicker. Java in our project file. In this class, we add a frame, a panel and several language buttons. I would like to talk about this process in details.

We first create a JFrame, a top-level window with a title and a border, and supports button components that close, amplify or downsize the window.

 JFrame

Then, we create a JPanel, and put it into the frame.

JPanel

Since we plan to localize our game into four languages, we create 4 language buttons and name them accordingly. We then add these buttons to the panel.

[ngg_images source=”galleries” container_ids=”6″ display_type=”photocrati-nextgen_basic_thumbnails” override_thumbnail_settings=”0″ thumbnail_width=”240″ thumbnail_height=”160″ thumbnail_crop=”1″ images_per_page=”20″ number_of_columns=”0″ ajax_pagination=”0″ show_all_in_lightbox=”0″ use_imagebrowser_effect=”0″ show_slideshow_link=”1″ slideshow_link_text=”[Show slideshow]” order_by=”sortorder” order_direction=”ASC” returns=”included” maximum_entity_count=”500″]

The new window looks like this at first.

Since it does not go with the style of the original interface, we customize it by changing the background color and font color of the language buttons.

Finally, the window appears like this:


ResourceBundle

In order to let the language buttons function and change the languages, we use the following code to declare the language, invoke the translation that has been stored in the corresponding property file named after the resource bundle, and start the game.

You may notice that we actually don’t directly start the game in the LanguagePicker. That is because we now have two threads running at the same time, the newly-added language window and the original one. In order to solve such a “traffic jam”, we create another class and put the following code inside so that the thread can be extended.

Besides, we also make a great effort to solve the concatenation issue during game localization by changing the default way of externalizing the stings. Plus, since we also localize our game to Spanish and Russian, and words in the interface of these two languages are too lengthy, we try to solve the truncation by choosing more concise translation, switching to a more appropriate font, breaking one string into two and relocating the strings.

The process is recorded in detail in our project showcase slides. Please feel free to have a look. You may also have fun playing with our localized Tetris game.