Browse Source

Added basic merge command

Armin Ronacher 9 years ago
parent
commit
603bab4b57
1 changed files with 20 additions and 0 deletions
  1. 20 0
      bin/merge-catalogs

+ 20 - 0
bin/merge-catalogs

@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+from babel.messages.pofile import read_po, write_po
+
+
+with open('src/sentry/locale/en/LC_MESSAGES/django.po') as f:
+    backend = read_po(f)
+with open('javascript.po') as f:
+    frontend = read_po(f)
+
+for message in frontend:
+    if message.id == '':
+        continue
+    old_msg = backend.get(message.id)
+    message.locations = sorted(
+        set(message.locations) | set(old_msg and old_msg.locations or ()))
+    backend[message.id] = message
+
+with open('final.po', 'w') as f:
+    write_po(f, backend)