Commits

Martin Geisler committed 6c68bd2

rst2html: look for .mo file next to destination file

Comments (0)

Files changed (2)

                       ENV={"PATH": "." + os.pathsep + os.environ["PATH"],
                            "LANGUAGE": lang})
 
-    if lang != "en":
-        mo = env.Command("locale/$LANG/LC_MESSAGES/kick-start.mo", "po/${LANG}.po",
-                         "msgfmt $SOURCE -o $TARGET")
-
     for txt in Flatten(txt_files):
         html = env.Command("$LANG/%s.html" % txt[4:-4], txt,
                            "rst2html $RSTFLAGS --time --language $RSTLANG"
                            " --no-compact-lists --no-compact-field-lists"
                            " $SOURCE $TARGET")
         if lang != "en":
+            mo = env.Command("$LANG/%s.mo" % txt[4:-4], "po/${LANG}.po",
+                             "msgfmt $SOURCE -o $TARGET")
             env.Depends(html, mo)
 
     for dot in Flatten(dot_files):
     pub.process_command_line()
     pub.set_io()
 
-    t = gettext.translation('kick-start', 'locale', fallback=True)
+    mofile = os.path.splitext(pub.settings._destination)[0] + '.mo'
+    if os.path.exists(mofile):
+        t = gettext.GNUTranslations(open(mofile, 'rb'))
+    else:
+        t = gettext.NullTranslations()
     pub.source = GettextSource(pub.source, t)
     pub.destination = SmartyPantsDestination(pub.destination)