Detect badly placed #textdomain strings (partial implementation of FR #10951).
Correct two mainline glitches detected by this code.
This commit is contained in:
parent
a5a8f77b06
commit
875f023721
3 changed files with 33 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
|||
#textdomain wesnoth-tb
|
||||
[terrain]
|
||||
#textdomain wesnoth-tb
|
||||
#impassable custom magic gate
|
||||
symbol_image=../scenery/gate-rusty-se
|
||||
id=magic_irongate
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#textdomain wesnoth
|
||||
|
||||
#define DAWN
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=dawn
|
||||
name= _ "Dawn"
|
||||
image=misc/schedule-dawn.png
|
||||
|
@ -14,7 +15,6 @@
|
|||
|
||||
#define MORNING
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=morning
|
||||
name= _ "Morning"
|
||||
image=misc/schedule-morning.png
|
||||
|
@ -25,7 +25,6 @@
|
|||
|
||||
#define AFTERNOON
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=afternoon
|
||||
name= _ "Afternoon"
|
||||
image=misc/schedule-afternoon.png
|
||||
|
@ -36,7 +35,6 @@
|
|||
|
||||
#define DUSK
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=dusk
|
||||
name= _ "Dusk"
|
||||
image=misc/schedule-dusk.png
|
||||
|
@ -50,7 +48,6 @@
|
|||
|
||||
#define FIRST_WATCH
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=first_watch
|
||||
name= _ "First Watch"
|
||||
image=misc/schedule-firstwatch.png
|
||||
|
@ -64,7 +61,6 @@
|
|||
|
||||
#define SECOND_WATCH
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=second_watch
|
||||
name= _ "Second Watch"
|
||||
image=misc/schedule-secondwatch.png
|
||||
|
@ -78,7 +74,6 @@
|
|||
|
||||
#define UNDERGROUND
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=underground
|
||||
name= _ "Underground"
|
||||
image=misc/schedule-underground.png
|
||||
|
@ -86,7 +81,6 @@
|
|||
lighter=underground_illum
|
||||
[/time]
|
||||
[illuminated_time]
|
||||
#textdomain wesnoth
|
||||
id=underground_illum
|
||||
name= _ "Underground"
|
||||
image=misc/schedule-underground-illum.png
|
||||
|
@ -95,7 +89,6 @@
|
|||
|
||||
#define DEEP_UNDERGROUND
|
||||
[time]
|
||||
#textdomain wesnoth
|
||||
id=deep_underground
|
||||
name= _ "Deep Underground"
|
||||
image=misc/schedule-underground.png
|
||||
|
@ -106,7 +99,6 @@
|
|||
lighter=deep_underground_illum
|
||||
[/time]
|
||||
[illuminated_time]
|
||||
#textdomain wesnoth
|
||||
id=deep_underground_illum
|
||||
name= _ "Deep Underground"
|
||||
image=misc/schedule-underground-illum.png
|
||||
|
|
|
@ -791,6 +791,18 @@ def sanity_check(filename, lines):
|
|||
m = re.match('# *wmllint: usage of "([^"]*)" is +(.*)', lines[i])
|
||||
if m:
|
||||
usage[m.group(1)] = m.group(2).strip()
|
||||
# Check for textdomain strings; should be exactly one, on line 1
|
||||
textdomains = []
|
||||
for i in range(len(lines)):
|
||||
if "#textdomain" in lines[i]:
|
||||
textdomains.append(i+1)
|
||||
if not textdomains:
|
||||
print '"%s", line 1: no textdomain string' % filename
|
||||
elif textdomains[0] == 1:
|
||||
pass
|
||||
elif len(textdomains) > 1:
|
||||
print '"%s", line %d: multiple textdomain strings on lines %s' % \
|
||||
(filename, textdomains[0], ", ".join(map(str, textdomains)))
|
||||
return modified
|
||||
|
||||
def consistency_check():
|
||||
|
@ -1397,7 +1409,7 @@ start_time=-150
|
|||
lines[i] = m.group(1) + image_block % (m.group(2), "ranged")
|
||||
modcount += 1
|
||||
# More syntax transformations would go here.
|
||||
return (lines, modcount)
|
||||
return modcount
|
||||
|
||||
# Generic machinery starts here
|
||||
|
||||
|
@ -1680,21 +1692,25 @@ def translator(filename, mapxforms, textxform):
|
|||
if tagstack:
|
||||
print >>sys.stderr, '"%s", line %d: tag stack nonempty (%s) at end of file.' % (filename, lineno, tagstack)
|
||||
tagstack = []
|
||||
# Perform semantic sanity checks
|
||||
modified |= sanity_check(filename, newdata)
|
||||
# OK, now perform WML rewrites
|
||||
(newdata, hacked) = hack_syntax(filename, newdata)
|
||||
# Run everything together
|
||||
filetext = "".join(newdata)
|
||||
if upconvert:
|
||||
# WML syntax changed in 1.3.5. The transformation cannot
|
||||
# conveniently be done line-by-line.
|
||||
transformed = re.sub(r"(if]|while])\s*\[or]([\w\W]*?)\[/or]\s*",
|
||||
r"\1\2", filetext);
|
||||
else:
|
||||
if iswml(filename):
|
||||
# Perform semantic sanity checks
|
||||
modified |= sanity_check(filename, newdata)
|
||||
# OK, now perform WML rewrites
|
||||
modified |= hack_syntax(filename, newdata)
|
||||
# Run everything together
|
||||
filetext = "".join(newdata)
|
||||
transformed = filetext
|
||||
if upconvert:
|
||||
# WML syntax changed in 1.3.5. The transformation cannot
|
||||
# conveniently be done line-by-line.
|
||||
transformed = re.sub(r"(if]|while])\s*\[or]([\w\W]*?)\[/or]\s*",
|
||||
r"\1\2", filetext);
|
||||
modified |= (transformed != filetext)
|
||||
else:
|
||||
# Map or mask -- just run everything together
|
||||
transformed = "".join(newdata)
|
||||
# Return None if the transformation functions made no changes.
|
||||
if modified or hacked or transformed != filetext:
|
||||
if modified:
|
||||
return transformed
|
||||
else:
|
||||
return None
|
||||
|
|
Loading…
Add table
Reference in a new issue