Browse Source

Configured extractor appropriately and added basic message merge support

Armin Ronacher 9 years ago
parent
commit
69e35396b0
2 changed files with 14 additions and 2 deletions
  1. 7 1
      bin/merge-catalogs
  2. 7 1
      webpack.config.js

+ 7 - 1
bin/merge-catalogs

@@ -1,6 +1,8 @@
 #!/usr/bin/env python
 
+import os
 import click
+
 from babel.messages.pofile import read_po, write_po
 
 
@@ -16,9 +18,13 @@ def merge_locations(locations, frontend_locations):
 @click.argument('locale')
 def cli(locale):
     catalog_file = 'src/sentry/locale/%s/LC_MESSAGES/django.po' % locale
+    frontend_file = 'build/javascript.po'
+    if not os.path.isfile(frontend_file):
+        return
+
     with open(catalog_file) as f:
         catalog = read_po(f)
-    with open('build/javascript.po') as f:
+    with open(frontend_file) as f:
         frontend = read_po(f)
 
     for frontend_msg in frontend:

+ 7 - 1
webpack.config.js

@@ -59,7 +59,13 @@ var config = {
           extra: {
             gettext: {
               fileName: 'build/javascript.po',
-              baseDirectory: path.join(__dirname, 'src/sentry')
+              baseDirectory: path.join(__dirname, 'src/sentry'),
+              functionNames: {
+                gettext: ["msgid"],
+                ngettext: ["msgid", "msgid_plural", "count"],
+                t: ["msgid"],
+                tn: ["msgid", "msgid_plural", "count"],
+              },
             }
           }
         }