Is there a way to download the translations and inject them into the game to save the waiting for the next release and also allow for a more interactive workflow?
Crowdin allows download but it gives a zip containing .ini files, and there are no .ini files in the Factorio directory inside Steam.
testing translations locally
-
- Inserter
- Posts: 23
- Joined: Sat Jul 23, 2016 5:53 am
- Contact:
-
- Inserter
- Posts: 40
- Joined: Wed Jan 10, 2018 7:12 pm
- Contact:
Re: testing translations locally
None that I know of but I'd love the opportunity, especially since the slow-down post release. I'm still fine tuning the translations and seeing it in-game helps a lot for context.
Currently primary Danish translator of Factorio. Feel free to contact me in regards to the translations.
- eradicator
- Smart Inserter
- Posts: 4644
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: testing translations locally
Not sure how the crowdin files look inside, but factorio locale.cfg files *are* ini files, they just have a different file extension. So if you're lucky it might be enough to rename them.gyorokpeter wrote: ↑Sun Aug 23, 2020 3:49 pmCrowdin allows download but it gives a zip containing .ini files, and there are no .ini files in the Factorio directory inside Steam.
Author of: Hand Crank Generator Deluxe, Screenshot Hotkey 2.0, /sudo
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
-
- Inserter
- Posts: 23
- Joined: Sat Jul 23, 2016 5:53 am
- Contact:
Re: testing translations locally
Turns out it's not a simple rename and overwrite. There are minor syntax differences in the files downloaded from Crowdin that Factorio chokes on:
unconfirmed-mod-changes="__1__ __plural_for_parameter_1_ {1 = mod | rest = mods} __ megváltozott.
CONTEXTREQUEST"
This two-line string is represented as a single string with an embedded \n in the equivalent .cfg file. (Ironically the translation itself is garbage and needs to be replaced.)
So I came up with the following conversion code:
unconfirmed-mod-changes="__1__ __plural_for_parameter_1_ {1 = mod | rest = mods} __ megváltozott.
CONTEXTREQUEST"
This two-line string is represented as a single string with an embedded \n in the equivalent .cfg file. (Ironically the translation itself is garbage and needs to be replaced.)
So I came up with the following conversion code:
Code: Select all
import subprocess
import os
import re
temp = "D:/Temp/FactorioTranslations"
subprocess.run(["D:/Program Files/7-Zip/7z", "e", "D:/Temp/Factorio (hu).zip", "-y", "-o"+temp])
files = os.listdir(temp)
def rpl1(src,dst):
lines=[]
for line in open(src, encoding='utf8'):
if line[-1:] == "\n":
line = line[:-1]
if len(line) == 0:
pass
elif re.match("^\[.*\]$", line):
lines.append(line)
elif re.match("^[^=]*=", line):
lines.append(line)
else:
lines[len(lines)-1] = lines[len(lines)-1]+"\\n"+line
open(dst, encoding='utf8', mode='w').write("\n".join(lines))
def rpl(curr):
currf = os.listdir(curr)
if not "hu" in currf:
print("no \"hu\" in {}".format(curr))
return
nxt = os.path.join(curr,"hu")
nxtf = os.listdir(nxt)
for f in nxtf:
if ".cfg" in f:
nxtf2 = os.path.join(nxt, f)
srcf = os.path.join(temp, f.replace(".cfg", ".ini"))
if not os.path.isfile(srcf):
print("no localized file for: {}".format(srcf))
else:
print("replacing {} with {}".format(nxtf2, srcf))
rpl1(srcf, nxtf2)
def rp(curr):
currf = os.listdir(curr)
for f in currf:
nxt = os.path.join(curr, f)
if f == "locale":
rpl(nxt)
elif os.path.isdir(nxt):
rp(nxt)
rp("D:/Program Files/Steam/steamapps/common/Factorio")
Re: testing translations locally
Well … if the translation itself does not contain newline characters, but \n instead, it's already half way there …
Re: testing translations locally
Whenever I wanted to test translations in the past, I would simply modify the .cfg files directly (and reload the game). Of course this is not very useful when you want to modify a large number of strings, but very convenient otherwise. Another alternative, for those who don't want to edit the original files, is to copy the relevant cfg files into a new folder with the same directory structure as the Factorio root, and turn it into a mod you can then turn on\off in-game (I'm not sure about specifics because I haven't done this in years, but that's the general idea).
Leading Hebrew translator of Factorio.
Who is online
Users browsing this forum: No registered users