Fixes a regression introduced in ea58bd1: child HTML tags in strings like <b> were ignored when consuming strings. Closes #244.

This commit is contained in:
Sebastian Ludwig 2018-05-21 14:26:30 +02:00
parent b52de34ce9
commit 5b2ddf3135
2 changed files with 17 additions and 1 deletions

View file

@ -67,7 +67,8 @@ module Twine
key = child.attributes['name']
set_translation_for_key(key, lang, child.text)
content = child.children.map(&:to_s).join
set_translation_for_key(key, lang, content)
set_comment_for_key(key, comment) if comment
comment = nil

View file

@ -101,6 +101,21 @@ class TestAndroidFormatter < FormatterTest
assert_equal 'This is\n a string', @empty_twine_file.definitions_by_key["foo"].translations['en']
end
def test_read_html_tags
content = <<-EOCONTENT
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="foo">Hello, <b>BOLD</b></string>
</resources>
EOCONTENT
io = StringIO.new(content)
@formatter.read io, 'en'
assert_equal 'Hello, <b>BOLD</b>', @empty_twine_file.definitions_by_key["foo"].translations['en']
end
def test_set_translation_converts_leading_spaces
@formatter.set_translation_for_key 'key1', 'en', "\u0020value"
assert_equal ' value', @empty_twine_file.definitions_by_key['key1'].translations['en']