Skip to content

Commit 8d1c2a9

Browse files
Python Util gen scripts are now binaries built from Pyinstaller
* Use build_gettext_catalog.exe to make a Pootle Client translation template * Use build_gettext_catalog_nsi.exe to make a Pootle installer translation template * Use build_locale_nsi.exe to generate a localized .nsi file * Use gen_error_wikitable.exe to make an Error Codes wiki table * Use pull_pootle_catalogs_main.bat to download PO files from pootle into repo * Use pull_pootle_menu_pics_main.bat to download translated main menu images from pootle into repo
1 parent 23f82fa commit 8d1c2a9

16 files changed

+778
-766
lines changed

utils/build_gettext_catalog.exe

3.57 MB
Binary file not shown.

utils/build_gettext_catalog_nsi.exe

3.58 MB
Binary file not shown.

utils/build_locale_nsi.exe

3.58 MB
Binary file not shown.

utils/gen_error_wikitable.exe

3.57 MB
Binary file not shown.

utils/pull_pootle_catalogs.exe

4.73 MB
Binary file not shown.

utils/pull_pootle_catalogs_main.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:: pull_pootle_catalogs with latest languages
2+
pull_pootle_catalogs -L ar,cs,de,es,et,fr,hr,hu,it,ja,lt,lv,nb,nl,pl,pt_BR,ro,ru,sk,sl,sv,tr,zh_CN

utils/pull_pootle_menu_pics.exe

4.75 MB
Binary file not shown.

utils/pull_pootle_menu_pics_main.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:: pull_pootle_menu_pics with latest languages
2+
pull_pootle_menu_pics -L ar,cs,de,es,et,fr,hr,hu,it,ja,lt,lv,nb,nl,pl,pt_BR,ro,ru,sk,sl,sv,tr,zh_CN

utils/src/build.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:: Ensure to execute pip install pyinstaller
2+
pyinstaller --distpath ../ --onefile build_gettext_catalog.py
3+
pyinstaller --distpath ../ --onefile build_gettext_catalog_nsi.py
4+
pyinstaller --distpath ../ --onefile build_locale_nsi.py
5+
pyinstaller --distpath ../ --onefile gen_error_wikitable.py
6+
pyinstaller --distpath ../ --onefile pull_pootle_catalogs.py
7+
pyinstaller --distpath ../ --onefile pull_pootle_menu_pics.py
8+
pause
Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,86 @@
1-
##############################################################################
2-
#
3-
# PROJECT: Multi Theft Auto v1.0
4-
# LICENSE: See LICENSE in the top level directory
5-
# FILE: utils/build_gettext_catalog.py
6-
# PURPOSE: Create a template .pot file from .cpp and .h project files for client and server
7-
# DEVELOPERS: Dan Chowdhury <>
8-
#
9-
# Multi Theft Auto is available from http://www.multitheftauto.com/
10-
#
11-
##############################################################################
12-
13-
import os
14-
import subprocess
15-
import tempfile
16-
from optparse import OptionParser
17-
18-
parser = OptionParser()
19-
parser.add_option("-e", "--exe", dest="exe",
20-
help="xgettext executable location", default="C:/Program Files (x86)/Poedit/GettextTools/bin/xgettext.exe" )
21-
#parser.add_option("-f", "--file", dest="output",
22-
# help="POT File output directory", default="messages")
23-
parser.add_option("-v", "--version", dest="version",
24-
help="MTA:SA Version to write to the POT file", default="1.x")
25-
26-
(options, args) = parser.parse_args()
27-
28-
directories = {
29-
"client.pot" : [ "../MTA10", "../Shared" ],
30-
#"../MTA10/locale/client.pot" : [ "../MTA10_Server", "../Shared" ],
31-
}
32-
33-
scanDirsList = []
34-
35-
fd,temp_path = tempfile.mkstemp()
36-
37-
# The objective here is to scan for all our .cpp's and .h's in each root directory
38-
# We then compile a list of these files into a temporary file, which is given to xgettext
39-
# xgettext then reads this list, and produces our template .po file which is renamed to .pot
40-
for output,dirList in directories.iteritems():
41-
scanDirsFile = open(temp_path, 'w')
42-
# Scan for .cpp and .h files
43-
for dir in dirList:
44-
for root,dirs,files in os.walk(dir):
45-
for file in files:
46-
filename,ext = os.path.splitext(file)
47-
if ext == ".c" or ext == ".cpp" or ext == ".h" or ext == ".hpp":
48-
filePath = os.path.abspath(os.path.join(root,file))
49-
print ( filePath )
50-
# Add each file to a list
51-
scanDirsList.append ( filePath + "\n" )
52-
53-
print ( "Files found: " + str(len(scanDirsList)) )
54-
55-
# Write this to our temporary file
56-
scanDirsFile.writelines(scanDirsList)
57-
scanDirsFile.close()
58-
59-
# If we have .pot in the destination, strip it (xgettext seems to append an extension regardless)
60-
path,ext = os.path.splitext(output)
61-
if ext == ".pot":
62-
output = path
63-
64-
# Give xgettext our temporary file to produce our .po
65-
cmdArgs = [options.exe,"-f",os.path.abspath(scanDirsFile.name),"-d",output,
66-
"--c++","--from-code=UTF-8","--add-comments",
67-
"--keyword=_", "--keyword=_td", "--keyword=_tn:1,2", "--keyword=_tc:1c,2", "--keyword=_tcn:1c,2,3",
68-
"--package-name=MTA San Andreas","--package-version="+options.version]
69-
70-
proc = subprocess.Popen(cmdArgs)
71-
stdout, stderr = proc.communicate()
72-
print stdout
73-
print stderr
74-
75-
#Rename our template to .pot (xgettext always outputs .po)
76-
if os.path.isfile(output + ".pot"):
77-
os.remove(output + ".pot")
78-
if os.path.isfile(output + ".po"):
79-
os.rename(output + ".po", output + ".pot")
80-
81-
# Delete our temporary file
82-
os.close(fd)
83-
os.remove(temp_path)
84-
85-
86-
print ( "POT Generation Operation Complete" )
1+
##############################################################################
2+
#
3+
# PROJECT: Multi Theft Auto v1.0
4+
# LICENSE: See LICENSE in the top level directory
5+
# FILE: utils/build_gettext_catalog.py
6+
# PURPOSE: Create a template .pot file from .cpp and .h project files for client and server
7+
# DEVELOPERS: Dan Chowdhury <>
8+
#
9+
# Multi Theft Auto is available from http://www.multitheftauto.com/
10+
#
11+
##############################################################################
12+
13+
import os
14+
import subprocess
15+
import tempfile
16+
from optparse import OptionParser
17+
18+
parser = OptionParser()
19+
parser.add_option("-e", "--exe", dest="exe",
20+
help="xgettext executable location", default="C:/Program Files (x86)/Poedit/GettextTools/bin/xgettext.exe" )
21+
#parser.add_option("-f", "--file", dest="output",
22+
# help="POT File output directory", default="messages")
23+
parser.add_option("-v", "--version", dest="version",
24+
help="MTA:SA Version to write to the POT file", default="1.x")
25+
26+
(options, args) = parser.parse_args()
27+
28+
directories = {
29+
"client.pot" : [ "../MTA10", "../Shared" ],
30+
#"../MTA10/locale/client.pot" : [ "../MTA10_Server", "../Shared" ],
31+
}
32+
33+
scanDirsList = []
34+
35+
fd,temp_path = tempfile.mkstemp()
36+
37+
# The objective here is to scan for all our .cpp's and .h's in each root directory
38+
# We then compile a list of these files into a temporary file, which is given to xgettext
39+
# xgettext then reads this list, and produces our template .po file which is renamed to .pot
40+
for output,dirList in directories.iteritems():
41+
scanDirsFile = open(temp_path, 'w')
42+
# Scan for .cpp and .h files
43+
for dir in dirList:
44+
for root,dirs,files in os.walk(dir):
45+
for file in files:
46+
filename,ext = os.path.splitext(file)
47+
if ext == ".c" or ext == ".cpp" or ext == ".h" or ext == ".hpp":
48+
filePath = os.path.abspath(os.path.join(root,file))
49+
print ( filePath )
50+
# Add each file to a list
51+
scanDirsList.append ( filePath + "\n" )
52+
53+
print ( "Files found: " + str(len(scanDirsList)) )
54+
55+
# Write this to our temporary file
56+
scanDirsFile.writelines(scanDirsList)
57+
scanDirsFile.close()
58+
59+
# If we have .pot in the destination, strip it (xgettext seems to append an extension regardless)
60+
path,ext = os.path.splitext(output)
61+
if ext == ".pot":
62+
output = path
63+
64+
# Give xgettext our temporary file to produce our .po
65+
cmdArgs = [options.exe,"-f",os.path.abspath(scanDirsFile.name),"-d",output,
66+
"--c++","--from-code=UTF-8","--add-comments",
67+
"--keyword=_", "--keyword=_td", "--keyword=_tn:1,2", "--keyword=_tc:1c,2", "--keyword=_tcn:1c,2,3",
68+
"--package-name=MTA San Andreas","--package-version="+options.version]
69+
70+
proc = subprocess.Popen(cmdArgs)
71+
stdout, stderr = proc.communicate()
72+
print stdout
73+
print stderr
74+
75+
#Rename our template to .pot (xgettext always outputs .po)
76+
if os.path.isfile(output + ".pot"):
77+
os.remove(output + ".pot")
78+
if os.path.isfile(output + ".po"):
79+
os.rename(output + ".po", output + ".pot")
80+
81+
# Delete our temporary file
82+
os.close(fd)
83+
os.remove(temp_path)
84+
85+
86+
print ( "POT Generation Operation Complete" )

0 commit comments

Comments
 (0)