From e13c2c2c7d55871e54f3d93abffed32521251841 Mon Sep 17 00:00:00 2001 From: Kevin Everets Date: Fri, 3 May 2013 16:58:47 -0400 Subject: [PATCH] Fix parsing of .po files for multiline msgstr It's valid for a msgstr to be broken over multiple lines, all of which are enclosed with ". To handle this, no longer iterate over the lines within an item but rather apply the matching to the entire item. --- lib/twine/formatters/gettext.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/twine/formatters/gettext.rb b/lib/twine/formatters/gettext.rb index 8dab8db..f7b27a4 100644 --- a/lib/twine/formatters/gettext.rb +++ b/lib/twine/formatters/gettext.rb @@ -35,19 +35,17 @@ module Twine value = nil comment = nil - for line in item.split(/\r?\n/) - comment_match = comment_regex.match(line) - if comment_match - comment = comment_match[1] - end - key_match = key_regex.match(line) - if key_match - key = key_match[1].gsub('\\"', '"') - end - value_match = value_regex.match(line) - if value_match - value = value_match[1].gsub('\\"', '"') - end + comment_match = comment_regex.match(item) + if comment_match + comment = comment_match[1] + end + key_match = key_regex.match(item) + if key_match + key = key_match[1].gsub('\\"', '"') + end + value_match = value_regex.match(item) + if value_match + value = value_match[1].gsub(/"\n"/, '').gsub('\\"', '"') end if key and key.length > 0 and value and value.length > 0 set_translation_for_key(key, lang, value)