Long description
This mod makes the game (almost entirely) playable when setting the language to Hebrew. This mod does not fix is multiline texts whose order remains upside-down...
IMPORTANT: This mod replaces some vanilla files which means it might interfere with the internal updates mechanism and will force you to fully reinstall the game when an update comes out. The mod didn't break the update 0.12.0 => 0.12.1, but who knows...
Pictures
Pictures
Version history
Version history
15.08.01 (01-08-15): Updated with the latest strings as of 0.12.2.
15.07.24 (24-07-15): Updated with the latest strings as of 0.12.1.
15.07.17 (17-07-15): First proper release.
Special Instructions
Special Instructions
Unlike a regular mod which only needs to be put in the mods folder, this mod requires you to change some core files by extracting the contents of EXTRACT_TO_GAME_FOLDER, as the name suggests, into the game folder (i.e. ...\Factorio\ ) while overwriting everything. Keeping the zip in \mods\ folder is entirely optional since enabling\disabling the mod in-game has no effect.
After overwriting the files, you can now safely and happily change the game's language to Hebrew!
Python3 Source Code
Python3 Source Code
Below is the Python3 source code (it will also run on python2, but the end result may suffer from some residual encoding issues)
#! python3
# coding=utf-8
import codecs
import os
import glob
import sys
OUTPUT_FOLDER_NAME = "output"
DEFAULT_FILE_EXT = "cfg"
def main(input_file_ext=DEFAULT_FILE_EXT):
# Initialize output folder:
if not os.path.exists(OUTPUT_FOLDER_NAME):
os.makedirs(OUTPUT_FOLDER_NAME)
else:
clear_folder(OUTPUT_FOLDER_NAME)
# Obtain list of all files that need processing:
for filename in glob.glob('*.' + input_file_ext):
f_in = codecs.open(filename, 'r', encoding='utf8')
f_out = codecs.open(os.path.join(OUTPUT_FOLDER_NAME, ''.join([filename[:-3], DEFAULT_FILE_EXT])),
'a+', encoding='utf8')
for line in f_in:
# Skip empty lines or lines where sections begin:
if line[0] in ["[", "\n", "\r"]:
f_out.write(line)
continue
split_ln = line.split('=')
eng_part = split_ln[0]
heb_part = split_ln[1].strip() # removing the newline at the end
tokens = list(reversed(heb_part.split(' ')))
for ind, token in enumerate(tokens, 0):
if not token: # skip empty lines
continue
if not all(ord(c) < 128 for c in token): # (supposed to) skip non-heb tokens
# rotate parentheses
if token[0] is '(':
token = ')' + token[1:]
if token[-1] is ')':
token = token[:-1] + '('
token = token[::-1]
tokens[ind] = token
if all(ord(c) < 128 for c in line):
f_out.write(line) # Supposed to fix the inverted fonts issue
else:
# f_out.write(eng_part + u"=\u200F" + ' '.join(tokens) + '\r\n')
f_out.write(eng_part + u"=" + ' '.join(tokens) + '\r\n')
# Note the RTL character, \u200F, that is added after the '='
# Close files
f_in.close()
f_out.close()
def clear_folder(path):
for root, dirs, files in os.walk(path, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
if __name__ == "__main__":
if len(sys.argv) == 2 and len(sys.argv[1]) == 3: # The 0th input is the script name, so we ignore it
main(input_file_ext=sys.argv[1])
else:
main() # read .cfg files by default
Notes
I'd appreciate tips on how to package the files such that no vanilla files need to be replaced when using the mod.
Re: [0.12.0]Hebrew RTL Fixer/Inverter
Posted: Fri Jul 17, 2015 7:36 pm
by Koub
Dev-il, would you please apply (and fill) the template you can find here in your first post ?
Thanks
Re: [0.12.0]Hebrew RTL Fixer/Inverter
Posted: Fri Jul 17, 2015 8:00 pm
by Dev-iL
Koub wrote:Dev-il, would you please apply (and fill) the template you can find here in your first post ?
Thanks
Thanks for pointing this out! I've applied the standardized formatting. Please tell me if there's anything else I should modify.
Re: [0.12.0]Hebrew RTL Fixer/Inverter
Posted: Sat Jul 18, 2015 1:33 am
by jockeril
Dev-iL wrote:
* This mod replaces some vanilla files which means it probably breaks the internal updates mechanism and will force you to fully reinstall the game when an update comes out.
* I'd appreciate tips on how to package the files such that no vanilla files need to be replaced when using the mod.
if you create your updated files (if needed) in a "locale/he" folder under your mod folder, you can solve both these problems
and did I see correctly ? is if already 0.12 ready ? (not really surprised, since I know what you do and how you do it... )
you must be the first 0.12 mod - congrats
Re: [0.12.0]Hebrew RTL Fixer/Inverter
Posted: Sat Jul 18, 2015 7:19 am
by Dev-iL
jockeril wrote:if you create your updated files (if needed) in a "locale/he" folder under your mod folder, you can solve both these problems
and did I see correctly ? is if already 0.12 ready ? (not really surprised, since I know what you do and how you do it... )
you must be the first 0.12 mod - congrats
Previously I did it with locale\he\.. but the game did not recognize the updated files for any of the scenarios/campaigns (bug?). This is why I did it with the overwrite method (which at least works).
It was actually 0.12-ready before as well, I just wrapped it in a nice format of a mod page
I need your help playing it in HEB and noticing any improper translations, then please suggest\fix\vote on crowdin, and I could update the mod with the new .ini\.cfg files (it doesn't have to coincide with new releases of the game as you understand).
Re: [0.12.0] Hebrew RTL Fixer/Inverter
Posted: Fri Jul 24, 2015 2:45 pm
by Dev-iL
Updated for 0.12.1. Note: due to a modification in the latest version, this (or changing core.cfg in some other way) is currently the only option to run the game in Hebrew.
Re: [0.12.1] Hebrew RTL Fixer/Inverter
Posted: Sat Aug 01, 2015 11:12 am
by Dev-iL
Updated with the latest strings as of 01 August 2015 (for v0.12.2)
Re: [0.12.X] Hebrew RTL Fixer/Inverter
Posted: Sat Aug 01, 2015 7:19 pm
by jockeril
קבל את השגיאה השבועית...
מסך הניקוד הפוך-בקטן.jpg (43.34 KiB) Viewed 17497 times
יש לך מושג איפה הטקסט הזה ? כי אני לא מצאתי אותו
Re: [0.12.X] Hebrew RTL Fixer/Inverter
Posted: Sun Aug 02, 2015 12:27 pm
by omri.kipi@gmail.co
תודה גבר
Re: [0.12.X] Hebrew RTL Fixer/Inverter
Posted: Sun Aug 02, 2015 8:23 pm
by Dev-iL
jockeril wrote:קבל את השגיאה השבועית...
מסך הניקוד הפוך-בקטן.jpg
יש לך מושג איפה הטקסט הזה ? כי אני לא מצאתי אותו
I can't reproduce your problem. Are you sure you're using {the latest version of} my mod? As of v0.12.2, my mod still produces better results than the inversion logic that comes with the game.
Whenever you want to locate a certain string within the translation files, go to the desired language and select the "all strings" display, then search for either the original or the translated string, and you could see the file it is located in (near the context of the string you chose in search results). In the example of the string you asked about, it is found in "freeplay" and in "sandbox".
Re: [0.12.X] Hebrew RTL Fixer/Inverter
Posted: Sun Aug 02, 2015 8:39 pm
by jockeril
חמש דקות אחרי שכתבתי את התגובה מצאתי את הטקסט בדיוק כמו שכתבת פה. אצלי הוא הפוך כי אני משתמש בתוסף שלך. לא ברור לי למה זה הפוך, חשבתי שיש עוד מקום שהמחרוזת הזו מתחבאת...
במה השתמשת פה freeplay או sandbox ?
ותכתוב בעברית - זה פוסט שרק קוראי עברית יכנסו אליו... בכלל לדעתי אתה צריך לעשות כמוני ולהוסיף טקסט בעברית לפוסט הראשוני במקביל לזה שבאנגלית - כי זה מיועד לקוראי עברית... אחרת למה אתה מתרגם את המשחק ?