]> pere.pagekite.me Git - text-free-culture-lessig.git/blob - scripts/translated_emdash_converter.rb
Merge pull request #37 from marsgui/french_po13
[text-free-culture-lessig.git] / scripts / translated_emdash_converter.rb
1 #!/usr/bin/env ruby
2
3 REPLACE_WITH = " – "
4
5 is_translation = false
6
7 lines = ARGF.readlines
8 lines.each_with_index do |line, i|
9 case line
10 when /^msgid/ then is_translation = false
11 when /^msgstr/ then is_translation = true
12 end
13
14 unless is_translation
15 next
16 end
17
18 if line =~ /^"—/
19 lines[i-1].sub!(/ *"$/, "\"")
20 end
21 if line =~ /—"$/
22 lines[i+1].sub!(/^" */, "\"")
23 end
24
25 line.gsub!(/ *— */, REPLACE_WITH)
26 end
27 puts lines