add script to automatically generate all languages
This commit is contained in:
0
scripts/__init__.py
Normal file
0
scripts/__init__.py
Normal file
13
scripts/compile_lang.py
Normal file
13
scripts/compile_lang.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import os, glob
|
||||||
|
from scripts import msgfmt
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
locale_path = os.path.abspath(os.path.join(script_dir, '..', 'locale'))
|
||||||
|
|
||||||
|
for name in glob.iglob(locale_path + '/**'):
|
||||||
|
if not os.path.isfile(name):
|
||||||
|
path = os.path.join(locale_path, name, 'LC_MESSAGES', 'lang')
|
||||||
|
sys.argv[1:] = [path + '.po']
|
||||||
|
msgfmt.main()
|
||||||
@@ -37,7 +37,6 @@ __version__ = "1.1"
|
|||||||
MESSAGES = {}
|
MESSAGES = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def usage(code, msg=''):
|
def usage(code, msg=''):
|
||||||
print(__doc__, file=sys.stderr)
|
print(__doc__, file=sys.stderr)
|
||||||
if msg:
|
if msg:
|
||||||
@@ -45,7 +44,6 @@ def usage(code, msg=''):
|
|||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add(id, str, fuzzy):
|
def add(id, str, fuzzy):
|
||||||
"Add a non-fuzzy translation to the dictionary."
|
"Add a non-fuzzy translation to the dictionary."
|
||||||
global MESSAGES
|
global MESSAGES
|
||||||
@@ -53,7 +51,6 @@ def add(id, str, fuzzy):
|
|||||||
MESSAGES[id] = str
|
MESSAGES[id] = str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generate():
|
def generate():
|
||||||
"Return the generated output."
|
"Return the generated output."
|
||||||
global MESSAGES
|
global MESSAGES
|
||||||
@@ -95,7 +92,6 @@ def generate():
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def make(filename, outfile):
|
def make(filename, outfile):
|
||||||
ID = 1
|
ID = 1
|
||||||
STR = 2
|
STR = 2
|
||||||
@@ -204,7 +200,6 @@ def make(filename, outfile):
|
|||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'hVo:',
|
opts, args = getopt.getopt(sys.argv[1:], 'hVo:',
|
||||||
|
|||||||
Reference in New Issue
Block a user