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.
This commit is contained in:
parent
51161194ed
commit
e13c2c2c7d
1 changed files with 11 additions and 13 deletions
|
@ -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)
|
||||
|
|
Reference in a new issue