Translation updates, updated submodule.
This commit is contained in:
@@ -196,6 +196,58 @@ def unescape_string_literal(literal_body: str) -> str:
|
||||
return "".join(result)
|
||||
|
||||
|
||||
def parse_string_literal_sequence(expr: str) -> Optional[str]:
|
||||
expr = expr.strip()
|
||||
if not expr or expr[0] != '"':
|
||||
return None
|
||||
|
||||
parts: List[str] = []
|
||||
i = 0
|
||||
length = len(expr)
|
||||
|
||||
while i < length:
|
||||
while i < length and expr[i].isspace():
|
||||
i += 1
|
||||
|
||||
if i >= length:
|
||||
break
|
||||
if expr[i] != '"':
|
||||
return None
|
||||
|
||||
i += 1
|
||||
literal_chars: List[str] = []
|
||||
escape = False
|
||||
|
||||
while i < length:
|
||||
ch = expr[i]
|
||||
if escape:
|
||||
literal_chars.append("\\" + ch)
|
||||
escape = False
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if ch == "\\":
|
||||
escape = True
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if ch == '"':
|
||||
i += 1
|
||||
break
|
||||
|
||||
literal_chars.append(ch)
|
||||
i += 1
|
||||
else:
|
||||
return None
|
||||
|
||||
parts.append(unescape_string_literal("".join(literal_chars)))
|
||||
|
||||
if not parts:
|
||||
return None
|
||||
|
||||
return "".join(parts)
|
||||
|
||||
|
||||
def expression_to_template(expr: str) -> Optional[str]:
|
||||
expr = expr.strip()
|
||||
if not expr:
|
||||
@@ -217,8 +269,9 @@ def expression_to_template(expr: str) -> Optional[str]:
|
||||
template_parts.append(passthrough_template)
|
||||
continue
|
||||
|
||||
if len(part) >= 2 and part[0] == '"' and part[-1] == '"':
|
||||
template_parts.append(unescape_string_literal(part[1:-1]))
|
||||
literal_sequence = parse_string_literal_sequence(part)
|
||||
if literal_sequence is not None:
|
||||
template_parts.append(literal_sequence)
|
||||
else:
|
||||
placeholder_count += 1
|
||||
template_parts.append(f"{{arg{placeholder_count}}}")
|
||||
|
||||
Reference in New Issue
Block a user