Python script to create any wiki language template file

Anything related to the content on our wiki (https://wiki.factorio.com/)

Moderator: Bilka

Tertius
Smart Inserter
Smart Inserter
Posts: 1163
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Python script to create any wiki language template file

Post by Tertius »

I made a small python script that scans the local game language files and creates the "| <english term> = <language term>" lines used in all of the language templates. Included are items, recipes and research.
You don't need to create the whole template manually, half of it is automated this way.

Before you start the script, edit create-factorio-language-templates.cfg and add the translation for "(Research)" for your language in a section with your language abbreviation. An example is present for German. Add your language, then proper research translations will be created as well.
Also enter some proper output_dir in def main in create-factorio-language-templates.py that will hold the output files.

Python 3.13 required (sorry, only with this version the allow_unnamed_section=True is allowed with ConfigParser. Without that option ConfigParser throws errors for the original game files, because there are files without sections at the top.

I attach the script, the config file and the template files I created, but without the Research translation. This way you don't need to run the script, if you cannot use python.

ps. ChatGPT is great for getting a start with such small tasks to work on. Am I an experienced python developer? No. Did I know you use configparser to read ini files? No. But ChatGPT did.
Attachments
create-factorio-language-templates.zip
(580 KiB) Downloaded 30 times
Post Reply

Return to “Wiki Talk”