don't use implicit $ in extract-po-strings

This commit is contained in:
Damien Elmes 2020-02-21 17:06:57 +10:00
parent f28b32cf75
commit a85bca51b2

View file

@ -10,7 +10,7 @@ import polib
# extract a translated string from the gettext catalogs and insert it into ftl # extract a translated string from the gettext catalogs and insert it into ftl
# eg: # eg:
# $ python extract-po-string.py media-check.ftl delete-unused "Delete Unused Media" "", 1 # $ python extract-po-string.py media-check.ftl delete-unused "Delete Unused Media" "", 1
# $ python extract-po-string.py media-check.ftl delete-unused "%(a)s %(b)s" "%(a)s=val1,%(b)s=val2" 0 # $ python extract-po-string.py media-check.ftl delete-unused "%(a)s %(b)s" "%(a)s=$val1,%(b)s=$val2" 0
ftl_filename, key, msgid, repls, dry_run = sys.argv[1:] ftl_filename, key, msgid, repls, dry_run = sys.argv[1:]
replacements = [] replacements = []
@ -34,7 +34,7 @@ for (lang, cat) in cats:
msg = entry.msgstr msg = entry.msgstr
if replacements: if replacements:
for (old,new) in replacements: for (old,new) in replacements:
msg = msg.replace(old, f"{{${new}}}") msg = msg.replace(old, f"{{{new}}}")
print(lang, "has", msg) print(lang, "has", msg)
to_insert.append((lang, msg)) to_insert.append((lang, msg))
break break
@ -47,7 +47,7 @@ for (lang, cat) in cats:
for _k, msg in plurals: for _k, msg in plurals:
if replacements: if replacements:
for (old,new) in replacements: for (old,new) in replacements:
msg = msg.replace(old, f"{{${new}}}") msg = msg.replace(old, f"{{{new}}}")
adjusted.append(msg) adjusted.append(msg)
print(lang, "has", adjusted) print(lang, "has", adjusted)
if len(adjusted) > 1: if len(adjusted) > 1: