Imagine you set up all localizable texts in your Unreal project and now you want to send them over to the localization company for translation process. However, the localization company of your choice doesn't want to work with PO files provided by Unreal; they want XLSX files instead.
Here comes the LocPyTools - this python program provides a set of tools that automatize generating a XLSX file with missing translations and rewrites Unreal PO files with translations read from existing XLSX documments.
Before using LocPyTools you need to learn about some basic assumptions takes during developing this program:
- all string tables used in UE project are created from data loaded from CSV files
- all localization data have been exported from UE built-in Localization system to a bunch of PO files
- the translation company of your choice uses only with XLSX files for texts translation
- texts IDs in XLSX files are composed with CSV file name and text key used in UE separated by the '+' sign: eg.: 'ST_SomeFile.csv+Some_Text_ID'
LocPyTools was developed and tested with Python 3.10. All source scripts can be found in LocalizationPyTools directory on this repository.
You can either run locpytools.py
script from LocalizationPyTool/Source directory on your own or use provided executable file available in LocalizationPyTools/dist directory.
The UETestProject directory contains an example project created in Unreal Engine, while the XlsxTranslations directory holds some translations for texts found in this project. Feel free to play with it and learn how to use the LocPyTools program.
In case of any questions you can contact me at sosnowska.kk@gmail.com.
This project is licensed under the MIT License. Learn more
Following paragraphs contain descriptions of all commands available in LocPyTools program.
It prints a short manual for the program.
It quits the program.
It generates the .config
file used by other tools. Note that this file is automatically generated at the start of the program if none .config
file has been found.
It runs the analyser tool for all XLSX files found in input directory. The result of this analysis is a dictionary with all translations for each found native text. All input arguments are read from config file (xlsxan
prefix).
- Run locpytools program. Make sure that the
.config
file exists - if not, you can generate one using themkconfig
command. - Make sure the
.config
file has proper data for arguments with prefixxlsxan
. - Run
xlsxan
command in locpytools program.
It runs the listmissingtexts
tool, which generates a new XLSX file with all missing translations.
First, it analyses all XLSX files with translations and register all translations in a dedicated dictionary. For this step, the xlsxan
tool is used.
After that, the program goes through all input CSV files (those files are used to create string tables used in UE project) and read their content. Each text ID from CSV file that is not in generated translations dictionary is written down into output XLSX file. As a result, the output XLSX file will contain all texts that are missing their translations.
- Run locpytools program. Make sure that the
.config
file exists - if not, you can generate one using themkconfig
command. - Make sure the
.config
file has proper data for arguments with prefixesxlsxan
andlmt
. - Run
lmt
command in locpytools program. - New
MissingTexts_XYZ.xlsx
file should be generated inside the path provided forlmt_xlsx_output_dir
argument. The XYZ in the file name will be replaced with a date and time of the file creation.
The lmt tool demands CSV files to be formatted with serveral rules, which are the following:
- in each row the cells are separated with
,
character - each cell must be encapsulated within quotation characters
"
- each text entry is contained in only one line. If you do need to create multi-line text, use
\r\n
formatting tag to create new line entry inside the source text - do not leave empty rows inside CSV file, as Unreal's Localization system might be not able to gather texts from such file
How BAD formatting looks like:
Key,SourceString,Comments
,,,
animal_cat,cat,A cat
,,,
animal_dog,dog,A dog
,,,
animal_cat_multiline,"This
is
THE CAT",A multi-line cat"
,,,
,,,
,,,
And now how GOOD formatting looks like:
"Key","SourceString","Comments"
"animal_cat","cat","A cat"
"animal_dog","dog","A dog"
"animal_cat_multiline","This\r\nis\r\nTHE CAT",The multi-line cat"
It runs the listchangedtexts
tool, which generates a new XLSX file with all source texts, that have been changed and may have outdated translations. Generally, this program helps to find all source texts, whose new meaning is completely different from the previous version, which invalidate their existing translations.
This simple program analyses data from the input PO file with native culture. It compares the content of the msgstr
and the msgid
parts of the localized text data. If msgstr
text is different than the text assigned to msgid
, it means that the source text in msgid
has changed, and the existing translation stored in msgstr
property may be outdated.
- Open your project in Unreal editor, go to the
Localization Dashboard
window and use Gather texts option to update localized texts archives in your project. - Run locpytools program. Make sure that the
.config
file exists - if not, you can generate one using themkconfig
command. - Make sure the
.config
file has proper data for arguments withlct
prefix. - Run
lct
command in locpytools program. - New
ChangedTexts_XYZ.xlsx
file should be generated inside the path provided forlct_xlsx_output_dir
argument. The XYZ in the file name will be replaced with a date and time of the file creation.
It runs the xlsxregistry
tool, which merges all texts entries from existing XLSX files with texts translations. The main purpose for this program is to speed up the process of looking for a particular text translations in order to update or remove them.
The generated XLSX registry provides following information for each localized text:
ID
- the text unique keySource Text
- the native textContext
- additional information for translatorsText Source File
- name of the file where the text is definedTTranslations Batch
- name of the file where we can find all translations for this text
- Run locpytools program. Make sure that the
.config
file exists - if not, you can generate one using themkconfig
command. - Make sure the
.config
file has proper data for arguments withxlsxreg
prefix. - Run
xlsxreg
command in locpytools program. - New
TranslationsRegistry_XYZ.xlsx
file should be generated inside the path provided forxlsxreg_output_dir
argument. The XYZ in the file name will be replaced with a date and time of the file creation.
It runs the poupdater
tool, that updates existing PO files with provided texts translations found in XLSX files.
First, it analyses all XLSX files with translations and register all translations in a dedicated dictionary. For this step, the xlsxan
tool is used.
After that, it goes through all input PO files (those are set of texts for all cultures used in UE project) found inside subdirectories of input directory and read their content. For each text ID msgctxt
that has existing translations in generated translations dictionary its assigned translation text msgstr
is replaced by updated translation from generated translations dictionary.
- Open your project in Unreal editor and go to the
Localization Dashboard
window. Use the Export texts option available underCultures
tab to generate a PO file for all cultures (you can also export texts to PO for each culture separatedly). - Run locpytools program. Make sure that the
.config
file exists - if not, you can generate one using themkconfig
command. - Make sure the
.config
file has proper data for arguments with prefixesxlsxan
andpou
. - Run
pou
command in locpytools program. - At this point, all PO files inside the directory path provided for
pou_po_source_dir
have been updated with the existing translations loaded from XLSX files. - Go back to the
Localization Dashboard
in the Unreal editor and use the Import texts option available underCultures
tab to load new translations for all cultures from updated PO files (you can also import texts from PO for each culture separatedly).