From: Johannes Larsen Date: Fri, 4 Sep 2015 19:26:55 +0000 (+0200) Subject: added script to convert translated —+space with " – " X-Git-Tag: edition-2015-10-10~184^2 X-Git-Url: https://pere.pagekite.me/gitweb/text-free-culture-lessig.git/commitdiff_plain/8fa31189cf8449d2e7a75fb173cb1ab16070fe0d added script to convert translated —+space with " – " --- diff --git a/scripts/translated_emdash_converter.rb b/scripts/translated_emdash_converter.rb new file mode 100755 index 0000000..45edeb0 --- /dev/null +++ b/scripts/translated_emdash_converter.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +REPLACE_WITH = " &ndash " + +is_translation = false + +lines = ARGF.readlines +lines.each_with_index do |line, i| + case line + when /^msgid/ then is_translation = false + when /^msgstr/ then is_translation = true + end + + unless is_translation + next + end + + if line =~ /^"—/ + lines[i-1].sub!(/ *"$/, "\"") + end + if line =~ /—"$/ + lines[i+1].sub!(/^" */, "\"") + end + + line.gsub!(/ *— */, REPLACE_WITH) +end +puts lines