L-Sherry / Localize-Me-Tools

Tools to help create/maintain translations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

These tools help to create translations for use by Localize-Me
The dependencies are Python >= 3.6 and pycrypto.

Localize-Me: https://github.com/L-Sherry/Localize-me

There are two tools: jsontr.py and packfile.py.  The first one creates
and update big translations packs, while the second essentially massage them.

jsontr.py
---------

This tool basically finds every string in the game and ask you to translate
each of them using a readline interface.

It takes an insane amount of options, that can be saved in a config file
for easier handling.  See --help for detail about them.

It possess five subcommands:
"saveconfig" to save the current command line option into a config file
"continue" to start or continue translating the game
"count" which simply count strings
"check" which make several attempts at finding problems with the translations.
"save_cache" which will cache the strings into a file for faster access later.

packfile.py
-----------

This tool can be used to create map files, split big packfiles using map files,
merge small packfiles into a big one (and optionally sort it), create a
packfile out of a untranslated and translated lang file or migrate pack
files to account for updates to the game.

- Merge multiple pack files into one, for easier editing:

./packfile merge my_pack_dir/ my_resulting_big_pack_file.json

- Create a map file from a big pack file, so you can split a big pack file into
  several, then actually split the big pack file

./packfile.py --map-file my-map-file.json mkmap my_big_pack_file.json
(you may customize my-map-file.json now...)
./packfile.py --map-file my-map-file.json split my_big_pack_file.json output_directory

- Diff two langfiles to create a pack file.
  (This only work for lang files, i.e. files under data/lang/)
./packfile.py difflang original/lang.en_US.json translated/lang.es_ES.json resulting_packfile.json

- Migrate one or multiple pack files with the latest version of the game:

Migrating pack files is done by calculating a migration plan file and then
apply it.  The migration plan file indicate how strings were changed/moved
between two versions.  Its format is simple enough that it may be edited by
hand to fine tune it and then share it with others.

To generate a migration plan, the jsontr.py's caching features are required.
Create two string caches for the two version of the game:
(both these commands may take some time to run)

./jsontr.py --game-dir path/to/old/crosscode/version --string-cache old_strings.json save_cache
./jsontr.py --game-dir path/to/new/crosscode/version --string-cache new_strings.json save_cache

At that point, old_strings.json and new_strings.json will contain all texts
used by both version of the game.

The next command will automatically calculate the best way to migrate
a pack file and write a "migration plan" file:

./packfile.py calcmigration old_strings.json new_strings.json migration_plan.json

The format of the migration plan file is easy to grok and modify.
It may even be improved and shared with others.

To do the actual migration using the migration plan file, run:

./packfile.py --string-cache new_cache.json migrate migration_plan.json old_packs_dir/ new_pack_dir/

migrate also works with single files.  It is also possible to replace
--string-cache new_cache.json with --game-dir path/to/new/crosscode/version
(e.g. in case you received the migration plan from somebody else)

About

Tools to help create/maintain translations

License:MIT License


Languages

Language:Python 100.0%