wmlxgettext: support double quotes in raw strings (fixes #4484)
This adds support for _<<map="{maps/01_First_Map.map}">>, as used in the editor file format documentation. This doesn't require another .pot update, because both the workaround in3d77d36
and this fix generate the same string in the .pot file. However, it does change the string that the Wesnoth executable looks for so that it matches the .pot file's contents. Cherry picked from commitc30c30acfc
, and additionally reverted commit3d77d36bb0
.
This commit is contained in:
parent
3f8a995ee0
commit
75f7cb1e85
3 changed files with 11 additions and 4 deletions
|
@ -13,6 +13,8 @@
|
|||
### Translations
|
||||
* Updated translations: Catalan, Chinese (Traditional), French, Portuguese (Brazil),
|
||||
Spanish
|
||||
### Miscellaneous and Bug Fixes
|
||||
* Added support to wmlxgettext for double-quote characters in translatable raw strings
|
||||
|
||||
## Version 1.14.15
|
||||
### Add-ons client
|
||||
|
|
|
@ -248,11 +248,13 @@ class PendingLuaString:
|
|||
|
||||
|
||||
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'\\')
|
||||
|
@ -275,7 +277,10 @@ class PendingWmlString:
|
|||
# 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,
|
||||
|
|
|
@ -169,7 +169,7 @@ class WmlStr02:
|
|||
'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)
|
||||
|
@ -249,7 +249,7 @@ class WmlStr01:
|
|||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue