Created
May 16, 2021 15:23
-
-
Save dmerejkowsky/7dfd39a03cfe40d86a88ed6fa070e472 to your computer and use it in GitHub Desktop.
git filter for .po translations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
from pathlib import Path | |
import sys | |
input = Path(sys.argv[1]) | |
for line in input.read_text().splitlines(): | |
# Ignore date of the modification | |
if line.startswith('"PO-Revision-Date:'): | |
continue | |
# Ignore source line number | |
if line.startswith("#:"): | |
continue | |
cleaned = line | |
# Cleanup quotes | |
if line.startswith('msgstr "') and line.endswith('"'): | |
cleaned = line[8:-1] | |
elif line.startswith('"') and line.endswith('"'): | |
cleaned = line[1:-1] | |
line = cleaned.replace('\\"', '"') | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without the filter:
With the filter: