From a84a84d8c5d9d0f5b1ceb78732cef05d563bcbdf Mon Sep 17 00:00:00 2001 From: Kevin Everets Date: Fri, 25 Jan 2013 13:11:21 -0500 Subject: [PATCH] Fix regex for reading gettext to be more lenient and remove extra logging We don't distinguish between the types of comments and should allow space between the field type and the value. Also, the extra logging was accidentally left in and should be removed --- lib/twine/formatters/gettext.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/twine/formatters/gettext.rb b/lib/twine/formatters/gettext.rb index f7e5bb7..8dab8db 100644 --- a/lib/twine/formatters/gettext.rb +++ b/lib/twine/formatters/gettext.rb @@ -26,9 +26,9 @@ module Twine end def read_file(path, lang) - comment_regex = /#. "(.*)"$/ - key_regex = /msgctxt "(.*)"$/ - value_regex = /msgstr "(.*)"$/m + comment_regex = /#.? *"(.*)"$/ + key_regex = /msgctxt *"(.*)"$/ + value_regex = /msgstr *"(.*)"$/m File.open(path, 'r:UTF-8') do |f| while item = f.gets("\n\n") key = nil @@ -49,7 +49,6 @@ module Twine value = value_match[1].gsub('\\"', '"') end end - puts "found item: #{key}" if key and key.length > 0 and value and value.length > 0 set_translation_for_key(key, lang, value) if comment and comment.length > 0