mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Make translations exit if symbol missing
This commit is contained in:
@@ -23,6 +23,7 @@ except NameError:
|
|||||||
@functools.lru_cache(maxsize=None)
|
@functools.lru_cache(maxsize=None)
|
||||||
def cjkFont():
|
def cjkFont():
|
||||||
from bdflib import reader as bdfreader
|
from bdflib import reader as bdfreader
|
||||||
|
|
||||||
with open(os.path.join(HERE, "wqy-bitmapsong/wenquanyi_9pt.bdf"), "rb") as f:
|
with open(os.path.join(HERE, "wqy-bitmapsong/wenquanyi_9pt.bdf"), "rb") as f:
|
||||||
return bdfreader.read_bdf(f)
|
return bdfreader.read_bdf(f)
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ def loadJson(fileName, skipFirstLine):
|
|||||||
|
|
||||||
|
|
||||||
def readTranslation(jsonDir, langCode):
|
def readTranslation(jsonDir, langCode):
|
||||||
fileName = 'translation_{}.json'.format(langCode)
|
fileName = "translation_{}.json".format(langCode)
|
||||||
|
|
||||||
fileWithPath = os.path.join(jsonDir, fileName)
|
fileWithPath = os.path.join(jsonDir, fileName)
|
||||||
|
|
||||||
@@ -184,8 +185,10 @@ def getLetterCounts(defs, lang):
|
|||||||
symbolCounts.reverse()
|
symbolCounts.reverse()
|
||||||
return symbolCounts
|
return symbolCounts
|
||||||
|
|
||||||
|
|
||||||
def getCJKGlyph(sym):
|
def getCJKGlyph(sym):
|
||||||
from bdflib.model import Glyph
|
from bdflib.model import Glyph
|
||||||
|
|
||||||
try:
|
try:
|
||||||
glyph: Glyph = cjkFont()[ord(sym)]
|
glyph: Glyph = cjkFont()[ord(sym)]
|
||||||
except:
|
except:
|
||||||
@@ -213,6 +216,7 @@ def getCJKGlyph(sym):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# A glyph in the font table is divided into upper and lower parts, each by
|
# A glyph in the font table is divided into upper and lower parts, each by
|
||||||
# 8px high. Each byte represents half if a column, with the LSB being the
|
# 8px high. Each byte represents half if a column, with the LSB being the
|
||||||
# top-most pixel. The data goes from the left-most to the right-most column
|
# top-most pixel. The data goes from the left-most to the right-most column
|
||||||
@@ -228,6 +232,7 @@ def getCJKGlyph(sym):
|
|||||||
s += f"0x{b:02X},"
|
s += f"0x{b:02X},"
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def getFontMapAndTable(textList):
|
def getFontMapAndTable(textList):
|
||||||
# the text list is sorted
|
# the text list is sorted
|
||||||
# allocate out these in their order as number codes
|
# allocate out these in their order as number codes
|
||||||
@@ -311,13 +316,14 @@ def convStr(symbolConversionTable, text):
|
|||||||
for c in text.replace("\\r", "").replace("\\n", "\n"):
|
for c in text.replace("\\r", "").replace("\\n", "\n"):
|
||||||
if c not in symbolConversionTable:
|
if c not in symbolConversionTable:
|
||||||
log("Missing font definition for {}".format(c))
|
log("Missing font definition for {}".format(c))
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
outputString = outputString + symbolConversionTable[c]
|
outputString = outputString + symbolConversionTable[c]
|
||||||
return outputString
|
return outputString
|
||||||
|
|
||||||
|
|
||||||
def writeLanguage(lang, defs, f):
|
def writeLanguage(lang, defs, f):
|
||||||
languageCode = lang['languageCode']
|
languageCode = lang["languageCode"]
|
||||||
log("Generating block for " + languageCode)
|
log("Generating block for " + languageCode)
|
||||||
# Iterate over all of the text to build up the symbols & counts
|
# Iterate over all of the text to build up the symbols & counts
|
||||||
textList = getLetterCounts(defs, lang)
|
textList = getLetterCounts(defs, lang)
|
||||||
@@ -516,10 +522,11 @@ def writeLanguage(lang, defs, f):
|
|||||||
)
|
)
|
||||||
|
|
||||||
f.write(to_unicode("};\n\n"))
|
f.write(to_unicode("};\n\n"))
|
||||||
f.write("const bool HasFahrenheit = " + (
|
f.write(
|
||||||
"true" if lang.get('tempUnitFahrenheit', True) else "false") +
|
"const bool HasFahrenheit = "
|
||||||
";\n")
|
+ ("true" if lang.get("tempUnitFahrenheit", True) else "false")
|
||||||
|
+ ";\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def readVersion(jsonDir):
|
def readVersion(jsonDir):
|
||||||
@@ -567,9 +574,9 @@ def orderOutput(langDict):
|
|||||||
def parseArgs():
|
def parseArgs():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--output', '-o',
|
"--output", "-o", help="Target file", type=argparse.FileType("w"), required=True
|
||||||
help='Target file', type=argparse.FileType('w'), required=True)
|
)
|
||||||
parser.add_argument('languageCode', help='Language to generate')
|
parser.add_argument("languageCode", help="Language to generate")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user