Maintaining Translations

From PMDOWiki

Translations must be updated before every new version is published. It is broken into 3 steps:

  • Strings Out: Get a sheet of all translatable strings from the game.
  • String Sync: A script is used to efficiently merge translation changes.
  • Strings In: Put all translatable strings into the game.

The user must manually kick off each step in sequence. The following article explains how each step works. It assumes that the user has cloned the PMDODump repository and set up debugging. File locations described are relative to the PMDODump folder.

Strings Out

This step takes all data files (moves, items, etc) and extracts their translatable strings to several files in DataAsset/String, all ending in .txt

Run the DataGenerator project (preferably in Debug mode) with the following arguments:

-asset ../../../../DumpAsset/ -gen ../../../../DataAsset -strings out


String Sync

Localization is done by gathering all of the strings in the project, and putting them onto a google Spreadsheet. PMDO officially uses this sheet, but any forked project can choose to roll their own.

The Spreadsheet is then updated by the translators, and those tables are copied back into the Project.

There are many places where strings need to be copied to and from. run_sync.py, found in the Scripts subfolder, is a script that is created to do all of that automatically.

First Time Setup

In order to run this script, you will need to follow the Prerequisites and Step 1 of Google Sheets API setup: https://developers.google.com/sheets/api/quickstart/python

Copy the client_secret.json to the working directory.

You must then get the ID of the google Spreadsheet (found in its URL) containing the translation data and save it to a file named sheet_id.txt, also in the working directory.

Script

string_sync.py is a simple python file. Run it from its own directory.

It will read the state of the google sheets, and the state of the strings in the Project, merging them together and writing back to both.

This means that both the Project strings and the strings in the google doc are affected in one step.

The specific files it affects are:

  • DataAsset/String/*.txt files, which are read in, and output to DataAsset/String/*.out.txt files.
  • DumpAsset/Strings/*.resx, which contain the original english strings and their translated counterparts for global strings.
  • DumpAsset/Strings/Languages.xml, which indicates which languages are supported in the game.
  • DumpAsset/Data/Script/*.resx, which contain the original english strings and their translated counterparts for map-specific strings.

The auto-merge code in string_sync.py uses the following rules for merging:

  • If there's a new string key that was added to the Project, it will be added to the Spreadsheet.
  • If there's a string key missing in the Project that exists in the Spreadsheet, it will be removed from the Spreadsheet.
  • If the english (aka, the default) translation in the Project is different from the translation on the Spreadsheet, then the english translation on the Spreadsheet is updated, and the other translations are marked red (R234 G153 B153).
  • The Project writes all english translations to the google Spreadsheet without question.
  • The google Spreadsheet writes all non-english translations to the Project without question.
  • The script can detect potential renames. If an english string from one key matches the english string of another key form the past, it will ask the user to resolve them manually.
  • The script assumes that the keys in the Spreadsheet have been organized to be in lexicographic case-insensitive order. If they aren't, then the script will throw an error!
  • You cannot add any non-english translations to the Project directly unless you expect them to be overwritten by the script the next time it's run. The google Spreadsheet writes all non-english translations to the Project without question!


Strings Out

This step takes all files in DataAsset/String that have the .out.txt suffix, and implants their translated strings into data files (moves, items, etc).

Run the DataGenerator project (preferably in Debug mode) with the following arguments:

-asset ../../../../DumpAsset/ -gen ../../../../DataAsset -strings in


The game is now updated with the most recent translations!