mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Lowercase
This commit is contained in:
parent
8608362e6a
commit
0582facfd2
1 changed files with 13 additions and 13 deletions
|
|
@ -44,27 +44,27 @@ def usage(code, msg=''):
|
||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
|
||||||
|
|
||||||
def add(MESSAGES, ctxt, id, str, fuzzy):
|
def add(messages, ctxt, id, str, fuzzy):
|
||||||
"Add a non-fuzzy translation to the dictionary."
|
"Add a non-fuzzy translation to the dictionary."
|
||||||
if not fuzzy and str:
|
if not fuzzy and str:
|
||||||
if ctxt is None:
|
if ctxt is None:
|
||||||
MESSAGES[id] = str
|
messages[id] = str
|
||||||
else:
|
else:
|
||||||
MESSAGES[b"%b\x04%b" % (ctxt, id)] = str
|
messages[b"%b\x04%b" % (ctxt, id)] = str
|
||||||
|
|
||||||
|
|
||||||
def generate(MESSAGES):
|
def generate(messages):
|
||||||
"Return the generated output."
|
"Return the generated output."
|
||||||
# the keys are sorted in the .mo file
|
# the keys are sorted in the .mo file
|
||||||
keys = sorted(MESSAGES.keys())
|
keys = sorted(messages.keys())
|
||||||
offsets = []
|
offsets = []
|
||||||
ids = strs = b''
|
ids = strs = b''
|
||||||
for id in keys:
|
for id in keys:
|
||||||
# For each string, we need size and file offset. Each string is NUL
|
# For each string, we need size and file offset. Each string is NUL
|
||||||
# terminated; the NUL does not count into the size.
|
# terminated; the NUL does not count into the size.
|
||||||
offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id])))
|
offsets.append((len(ids), len(id), len(strs), len(messages[id])))
|
||||||
ids += id + b'\0'
|
ids += id + b'\0'
|
||||||
strs += MESSAGES[id] + b'\0'
|
strs += messages[id] + b'\0'
|
||||||
output = ''
|
output = ''
|
||||||
# The header is 7 32-bit unsigned integers. We don't use hash tables, so
|
# The header is 7 32-bit unsigned integers. We don't use hash tables, so
|
||||||
# the keys start right after the index tables.
|
# the keys start right after the index tables.
|
||||||
|
|
@ -94,7 +94,7 @@ def generate(MESSAGES):
|
||||||
|
|
||||||
|
|
||||||
def make(filename, outfile):
|
def make(filename, outfile):
|
||||||
MESSAGES = {}
|
messages = {}
|
||||||
ID = 1
|
ID = 1
|
||||||
STR = 2
|
STR = 2
|
||||||
CTXT = 3
|
CTXT = 3
|
||||||
|
|
@ -136,7 +136,7 @@ def make(filename, outfile):
|
||||||
lno += 1
|
lno += 1
|
||||||
# If we get a comment line after a msgstr, this is a new entry
|
# If we get a comment line after a msgstr, this is a new entry
|
||||||
if l[0] == '#' and section == STR:
|
if l[0] == '#' and section == STR:
|
||||||
add(MESSAGES, msgctxt, msgid, msgstr, fuzzy)
|
add(messages, msgctxt, msgid, msgstr, fuzzy)
|
||||||
section = msgctxt = None
|
section = msgctxt = None
|
||||||
fuzzy = 0
|
fuzzy = 0
|
||||||
# Record a fuzzy mark
|
# Record a fuzzy mark
|
||||||
|
|
@ -148,7 +148,7 @@ def make(filename, outfile):
|
||||||
# Now we are in a msgid or msgctxt section, output previous section
|
# Now we are in a msgid or msgctxt section, output previous section
|
||||||
if l.startswith('msgctxt'):
|
if l.startswith('msgctxt'):
|
||||||
if section == STR:
|
if section == STR:
|
||||||
add(MESSAGES, msgctxt, msgid, msgstr, fuzzy)
|
add(messages, msgctxt, msgid, msgstr, fuzzy)
|
||||||
section = CTXT
|
section = CTXT
|
||||||
l = l[7:]
|
l = l[7:]
|
||||||
msgctxt = b''
|
msgctxt = b''
|
||||||
|
|
@ -165,7 +165,7 @@ def make(filename, outfile):
|
||||||
charset = p.parsestr(msgstr.decode(encoding)).get_content_charset()
|
charset = p.parsestr(msgstr.decode(encoding)).get_content_charset()
|
||||||
if charset:
|
if charset:
|
||||||
encoding = charset
|
encoding = charset
|
||||||
add(MESSAGES, msgctxt, msgid, msgstr, fuzzy)
|
add(messages, msgctxt, msgid, msgstr, fuzzy)
|
||||||
msgctxt = None
|
msgctxt = None
|
||||||
section = ID
|
section = ID
|
||||||
l = l[5:]
|
l = l[5:]
|
||||||
|
|
@ -215,10 +215,10 @@ def make(filename, outfile):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# Add last entry
|
# Add last entry
|
||||||
if section == STR:
|
if section == STR:
|
||||||
add(MESSAGES, msgctxt, msgid, msgstr, fuzzy)
|
add(messages, msgctxt, msgid, msgstr, fuzzy)
|
||||||
|
|
||||||
# Compute output
|
# Compute output
|
||||||
output = generate(MESSAGES)
|
output = generate(messages)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(outfile,"wb") as f:
|
with open(outfile,"wb") as f:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue