]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - fixup-migrate-gettext.rb
Updated German and Polish proof reading pages.
[text-madewithcc.git] / fixup-migrate-gettext.rb
index 8a2f198492c35ed1a54b6ba32521e2eb69c4a248..b2d9c7ca28c4f6326bda2080e3a3528e666eae79 100755 (executable)
@@ -88,6 +88,9 @@ class PoStr
     if '' != @type
       print "#. type:%s\n" % [@type]
     end
+    if @location
+      print "#: %s:%s\n" % [@location[:file], @location[:line]]
+    end
     if fuzzy?
       print "#, fuzzy\n"
       if '' != prevstr()
@@ -126,22 +129,23 @@ strings = File.open(file,'r').read.split(/\n\n/)[1..-1].map {|str| PoStr.new(str
 
 c = 0
 strings.each do |entry|
-  if entry.fuzzy?
-    # Ignore whitespace changes between prev and src
-    entry.prevclean = entry.prevstr().gsub(/ +/, ' ')
-    entry.srcclean = entry.srcstr().gsub(/ +/, ' ')
+  # Ignore whitespace changes between prev and src
+  entry.prevclean = entry.prevstr().gsub(/ +/, ' ')
+  entry.srcclean = entry.srcstr().gsub(/ +/, ' ')
     
+  if entry.fuzzy?
     if entry.prevclean == entry.srcclean
       entry.status = ''
-      #print "clear fuzzy (space)\n"
+      #print "clear fuzzy (space)\n"
       c = c + 1
+      entry.output
       next
     end
 
     # Rewrite title strings, which lost '#' at the front
     if entry.prevclean.gsub(/^#+ +/, '') == entry.srcclean
+      # FIXME Not safe to clear fuzzy flag, might have bogus translation
       entry.status = ''
-      # FIXME
       if entry.dest[0].gsub!(/^#+ +/, '') ||
          ('' == entry.dest[0] && entry.dest[1].gsub!(/^#+ +/, ''))
         #print "cleared fuzzy (title)\n"
@@ -177,6 +181,15 @@ strings.each do |entry|
       end
     end
   end
+
+  # Copy image references and single URLs unchanged, even for non-fuzzies
+  if entry.prevclean =~ /!\[\]\(Pictures\// ||
+     entry.srcclean =~ /^<ulink url=\\\".+\\\"\/>$/
+    entry.dest = entry.src.clone()
+    entry.status = ''
+    c = c + 1
+  end
+
   entry.output
 end
-print "# Would clear %d fuzzy\n" % [c]
+print "# Cleared %d fuzzy strings\n" % [c]