Our Game and Entertainment Division has released an English translation of the PDF version of the internal training book “Unity Performance Tuning Bible,” which was published in August 2022.

Unity Performance Tuning Bible English Edition
Unity Performance Tuning Bible English Edition

https://github.com/CyberAgentGameEntertainment/UnityPerformanceTuningBible/blob/main/README_EN.md

In this article, we will introduce the background of why we decided to create an English version, and then the techniques of machine translation we used to improve translation quality.

By the way we only released English version, but you can translate to other languages by yourself from above link. Please read documents and try it.

Introduction

The release of the “Unity Performance Tuning Bible” received a lot of attention, and while most of the feedback came from Japanese users, we also received unexpected responses from overseas, requesting a translation via issue on the GitHub repository.

Our team discussed the possibility of an English translation, but it was impossible to ask the Unity engineers who wrote the book to translate it again due to the workload. Also, since we planned to provide the translation for free, we could not spend too much on translation costs. Therefore, we explored the possibility of a low-cost translation based on machine translation.

As a result, we were able to create a translation with a reasonable cost, an acceptable level of translation accuracy, and a readable layout. In this article, we will introduce the methods that supports the translation of the PDF book by the machine translation and hope to contribute to the translation techniques.

Difficulty of machine translation for books

When translating formatted text such as PDF, a significant problem is that the length of the text changes after translation, which can cause destructive layout issues. Japanese, in particular, is a language with a high information density among the world’s languages, and when translated into English, the number of characters increases by two to three times. Although it is possible to reduce the absolute width by reducing the font size, it is difficult to maintain the layout while the length of the text changes.

While there is a risk of significant layout issues, it is still attractive to have a service that can translate PDF without compromising the layout. Therefore, we compared and discussed two methods: using an external service to translate PDF as it is, on the other hand translating the original text file and converting it into PDF. We ultimately chose the latter method because the former did not meet the quality standards, but we will describes the process, including the techniques we used.

Technology for translating PDF as it is

There are several services available that can translate PDF while maintaining the layout. As previously mentioned, the ability to translate PDF without incurring additional costs is very appealing. Therefore, we first tried out a service that utilized this technology. However, it’s important to note that these services do not translate text in images.

Google Translation Hub

Translation Hub is a managed service announced by Google in 2022 that translates to 135 languages while maintaining the layout and manages the translation. It can be used for simple translation, but you can also build a translation workflow that includes translation correction by human translators. The cost starts at $0.15 per page, so translating the nearly 300-page alone would cost $45.

The result of the translation test is shown below.

Translated by Google Translation Hub
Translated by Google Translation Hub

Although there are some unknown symbols, we felt that the layout was maintained, and the translation accuracy was high. However, as shown in the following figure, layout issues occurred on pages with complex layouts, making it difficult to adopt the service.

Translated by Google Translation Hub
Translated by Google Translation Hub

DeepL

DeepL, which is known for its high translation accuracy in machine translation, also offers a direct PDF translation service. However, the result was disappointing. As shown in the figure below, the font size fluctuates in places, and the translation content itself includes non-existent words such as “formance,” making it difficult to use.

Translated by DeepL
Translated by DeepL

The cost is a monthly fee, starting at $10.49 per month. This cost does not increase even when dealing with books because it is not charged per page. However, each pricing plan has a file size limit, so it is not possible to translate a PDF that exceeds the limit.

Considerations

The PDF that we translated was output using a typesetting software based on a technology called tex, so it may have been affected by factors different from those of a normal PDF. Therefore, we gave up on direct translation from PDF and decided to try translating the text file before PDF conversion.

Direct Translation of Re:VIEW Text

The Unity Performance Tuning Bible was written using Re:VIEW, an open-source software for typesetting. We extracted sample text from the book.

==={start_tuning_any_degration} 性能低下の種類
性能低下といってもそれぞれが指し示すものは違うでしょう。
本書では大別して以下の3つと定義します。(@<img>{degration})
//image[degration][性能低下の原因]

まずクラッシュする場合は@<em>{「メモリ超過」}か@<em>{「プログラムの実行エラー」}の2種類に大別されるでしょう。
後者についてはパフォーマンスチューニングの領域ではないため、具体的な内容は本書では取り扱いません。

次に画面の処理落ちやロードが長いのは@<em>{「CPUやGPUの処理時間」}が原因の大半を占めるでしょう。
以降では「メモリ」と「処理時間」に焦点を当てて性能低下を深掘ります。

The meaning of Re:VIEW notation is as follows:

==={} Header: level is differ with number of =.
//image[][] Image embedding: specify the file name and image caption.
@<img>{} Image reference
@<em>{} Emphasis

When using machine translation, if these notations are not handled correctly, there is a risk that the translation result will be unnatural, such as splitting the text into unnatural sections. Therefore, we decided to use the XML document feature in DeepL API to handle tags and tried translation.

DeepL API

DeepL API allows you to translate using an API, and it has many features that are not available on the web version. One of them is the translation function for XML documents. This function enables translation that considers tags, such as the following Japanese example:

日本語の説明は<b>こちら</b>です。

English translation:

Japanese description is <b>here</b>.

There are no translation services that can handle Re:VIEW formats, but we found that machine translation was possible if we could convert them to and from XML formats. Therefore, we created a dedicated Python script for converting between formats.

Translation flow
Translation flow

As long as the XML syntax is followed, we should be able to use our original tags, so we decided to convert the previous sample into the following XML document.

<h3 start_tuning_any_degration>性能低下の種類</h3>
性能低下といってもそれぞれが指し示すものは違うでしょう。
本書では大別して以下の3つと定義します。(<img degration/>)
<image degration>性能低下の原因</image>

まずクラッシュする場合は<em>「メモリ超過」</em>か<em>「プログラムの実行エラー」</em>の2種類に大別されるでしょう。
後者についてはパフォーマンスチューニングの領域ではないため、具体的な内容は本書では取り扱いません。

次に画面の処理落ちやロードが長いのは<em>「CPUやGPUの処理時間」</em>が原因の大半を占めるでしょう。
以降では「メモリ」と「処理時間」に焦点を当てて性能低下を深掘ります。

We created a custom tag while basing it on the Re:VIEW tag name, and by embedding the reference ID in the tag to exclude from translation. We set the text we wanted to translate as the inner text of the tag. We translated this XML by DeepL API, the result is as follows:

<h3 start_tuning_any_degration> Types of Performance Degradation</h3>
Performance degradation may refer to different things.
In this document, we define the three broad categories as follows. ( <imgref degration/>)
<image degration> Causes of performance degradation</image>

First, crashes can be classified into two main types: <em>"memory overflow" or</em><em>"program execution error</em>.
The latter is not the domain of performance tuning, so the specifics will not be covered in this document.

Next, <em>"CPU and GPU processing time"</em> will probably account for the majority of screen dropouts and long loading times.
In the following sections, we will focus on "memory" and "processing time" to delve deeper into performance degradation.

Although there are some shortcomings such as the presence of “or” within the em tag, the translation considering the tags is very good.

Because Re:VIEW notation includes complex notations such as source code and tables, creating a tool of syntax tree is very time-consuming. Therefore, this time, we decided to replace tags by applying regular expressions for each line.

After adjusting the text machine-translated in this way, we used it almost as it is in the final draft. Of course, the accuracy will decrease compared to when a human translates it, but we thought that it would be possible to read it while taking into account some mistranslations if you read it with the assumption of machine translation.

Conclusion

In this article, we introduced the techniques we used to translate the “Unity Performance Tuning Bible” into English using machine translation. Although there were some difficulties in maintaining the layout, we were able to create a translation with reasonable cost, acceptable translation accuracy, and readable layout. We hope that this article will contribute to the improvement of translation technology for books.

2014年新卒入社の何でも屋エンジニアです。株式会社QualiArtsで基盤開発に従事したあと、SGEコア技術本部(コアテク)を立ち上げ開発責任者としてゲーム事業部全体の開発効率と品質の向上に取り組んでいます。