Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dmerejkowsky
Created May 16, 2021 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmerejkowsky/7dfd39a03cfe40d86a88ed6fa070e472 to your computer and use it in GitHub Desktop.
Save dmerejkowsky/7dfd39a03cfe40d86a88ed6fa070e472 to your computer and use it in GitHub Desktop.
git filter for .po translations
#!/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)
@dmerejkowsky
Copy link
Author

dmerejkowsky commented May 16, 2021

Without the filter:

diff --git a/library/configparser.po b/library/configparser.po
index dc8d9797..5d6c57bf 100644
--- a/library/configparser.po
+++ b/library/configparser.po
@@ -6,7 +6,7 @@ msgstr ""
 "Project-Id-Version: Python 3\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2020-10-01 16:00+0200\n"
-"PO-Revision-Date: 2021-05-16 17:05+0200\n"
+"PO-Revision-Date: 2021-05-16 17:17+0200\n"
 "Language-Team: FRENCH <traductions@lists.afpy.org>\n"
 "Language: fr\n"
 "MIME-Version: 1.0\n"
@@ -139,7 +139,7 @@ msgid ""
 "other datatypes, you should convert on your own:"
 msgstr ""
 "Les lecteurs de configuration n'essayent jamais de deviner le type des "
-"valeur présentes dans les fichiers de configuration, et elles sont toujours "
+"valeurs présentes dans les fichiers de configuration, et elles sont toujours "
 "stockées en tant que chaînes de caractères. Ainsi, si vous avez besoin d'un "
 "type différent, vous devez effectuer la conversion vous-même :"

With the filter:

diff --git a/library/configparser.po b/library/configparser.po
index dc8d9797..5d6c57bf 100644
--- a/library/configparser.po
+++ b/library/configparser.po
@@ -122,7 +122,7 @@ always storing them internally as strings.  This means that if you need
 other datatypes, you should convert on your own:
 
 Les lecteurs de configuration n'essayent jamais de deviner le type des 
-valeur présentes dans les fichiers de configuration, et elles sont toujours 
+valeurs présentes dans les fichiers de configuration, et elles sont toujours 
 stockées en tant que chaînes de caractères. Ainsi, si vous avez besoin d'un 
 type différent, vous devez effectuer la conversion vous-même :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment