Name: Factorio_HebInvert
Description: Takes care of reverse Hebrew text. Enabling/disabling this mod has no effect, because if installed correctly, it irreversibly replaces game files.
License: http://www.wtfpl.net/.
Version: 15.08.01
Release: 2015-08-01
Tested-With-Factorio-Version: 0.12.2
Category: Other
Tags: Free, Translation, RTL, Hebrew
Download-Url: https://forums.factorio.com/forum/dow ... hp?id=5020
Website: https://forums.factorio.com/forum/vie ... 91&t=13539
License
License
Copyright ยฉ 2015 Dev-iL 8168@factorioforums
This work is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
Copyright ยฉ 2015 Dev-iL 8168@factorioforums
This work is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
Long description
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...
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.
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!
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)
Below is the Python3 source code (it will also run on python2, but the end result may suffer from some residual encoding issues)
Code: Select all
#! 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.