Skip to content

Commit

Permalink
wmlxgettext: support double quotes in raw strings (fixes #4484)
Browse files Browse the repository at this point in the history
This adds support for _<<map="{maps/01_First_Map.map}">>.
  • Loading branch information
stevecotton committed Oct 19, 2019
1 parent 3535cee commit c30c30a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -92,6 +92,7 @@
* On windows, relative paths that start with `.\` are not deprecated
* Removed incomplete joystick support.
* Removed option to disable unit and item halos.
* Added support to wmlxgettext for double-quote characters in translatable raw strings

## Version 1.15.1
### Editor
Expand Down
9 changes: 7 additions & 2 deletions data/tools/pywmlx/state/machine.py
Expand Up @@ -248,11 +248,13 @@ def store(self):


class PendingWmlString:
def __init__(self, lineno, wmlstring, ismultiline, istranslatable):
def __init__(self, lineno, wmlstring, ismultiline, istranslatable, israw):
"""The israw argument indicates a << >> delimited string"""
self.lineno = lineno
self.wmlstring = wmlstring.replace('\\', r'\\')
self.ismultiline = ismultiline
self.istranslatable = istranslatable
self.israw = israw

def addline(self, value):
self.wmlstring = self.wmlstring + '\n' + value.replace('\\', r'\\')
Expand All @@ -275,7 +277,10 @@ def store(self):
# so, using "if errcode != 1"
# we will add the translatable string ONLY if it is NOT empty
_linenosub += 1
self.wmlstring = re.sub('""', r'\"', self.wmlstring)
if self.israw:
self.wmlstring = re.sub('"', r'\"', self.wmlstring)
else:
self.wmlstring = re.sub('""', r'\"', self.wmlstring)
pywmlx.nodemanip.addNodeSentence(self.wmlstring,
ismultiline=self.ismultiline,
lineno=self.lineno,
Expand Down
4 changes: 2 additions & 2 deletions data/tools/pywmlx/state/wml_states.py
Expand Up @@ -169,7 +169,7 @@ def run(self, xline, lineno, match):
'please report a bug if you encounter this error message')
pywmlx.state.machine._pending_wmlstring = (
pywmlx.state.machine.PendingWmlString(
lineno, loc_string, loc_multiline, loc_translatable
lineno, loc_string, loc_multiline, loc_translatable, israw=True
)
)
return (xline, _nextstate)
Expand Down Expand Up @@ -249,7 +249,7 @@ def run(self, xline, lineno, match):
xline = xline [ match.end(): ]
pywmlx.state.machine._pending_wmlstring = (
pywmlx.state.machine.PendingWmlString(
lineno, match.group(2), loc_multiline, loc_translatable
lineno, match.group(2), loc_multiline, loc_translatable, israw=False
)
)
return (xline, _nextstate)
Expand Down

0 comments on commit c30c30a

Please sign in to comment.