From 1b9aaf5a5909f130ede03bcab8be4aadaf9868d1 Mon Sep 17 00:00:00 2001 From: Roman Tsisyk Date: Tue, 2 Nov 2021 12:26:34 +0300 Subject: [PATCH] Tune whitespacing settings to be compatible with Weblate Signed-off-by: Roman Tsisyk --- lib/twine/formatters/abstract.rb | 4 ++-- lib/twine/formatters/android.rb | 18 +++++++++--------- lib/twine/formatters/apple.rb | 6 +++--- lib/twine/formatters/apple_plural.rb | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/twine/formatters/abstract.rb b/lib/twine/formatters/abstract.rb index ad70f3aa..6e96a1d1 100644 --- a/lib/twine/formatters/abstract.rb +++ b/lib/twine/formatters/abstract.rb @@ -103,7 +103,7 @@ def format_file(lang) header = format_header(lang) result = "" - result += header + "\n" if header + result += header if header result += format_sections(processed_twine_file, lang) end @@ -130,7 +130,7 @@ def format_section(section, lang) if section.name && section.name.length > 0 section_header = format_section_header(section) - result += "\n#{section_header}" if section_header + result += "#{section_header}" if section_header end definitions.map! { |definition| format_definition(definition, lang) } diff --git a/lib/twine/formatters/android.rb b/lib/twine/formatters/android.rb index 01468cf8..34adbed8 100644 --- a/lib/twine/formatters/android.rb +++ b/lib/twine/formatters/android.rb @@ -94,33 +94,33 @@ def read(io, lang) end def format_header(lang) - "\n\n\n" + "\n" end def format_sections(twine_file, lang) - result = '' + result = "\n" result += super + "\n" - result += "\n" + result += "" end def format_section_header(section) - "\t" + " " end def format_comment(definition, lang) - "\t\n" if definition.comment + " \n" if definition.comment end def key_value_pattern - "\t%{value}" + " %{value}" end def format_plural_keys(key, plural_hash) - result = "\t\n" - result += plural_hash.map{|quantity,value| "\t#{' ' * 2}#{escape_value(value)}"}.join("\n") - result += "\n\t" + result = " \n" + result += plural_hash.map{|quantity,value| " #{' ' * 4}#{escape_value(value)}"}.join("\n") + result += "\n " end def gsub_unless(text, pattern, replacement) diff --git a/lib/twine/formatters/apple.rb b/lib/twine/formatters/apple.rb index 62dfcc05..47dbc2bc 100644 --- a/lib/twine/formatters/apple.rb +++ b/lib/twine/formatters/apple.rb @@ -68,15 +68,15 @@ def format_header(lang) end def format_section_header(section) - "/********** #{section.name} **********/\n" + "\n\n/********** #{section.name} **********/\n" end def key_value_pattern - "\"%{key}\" = \"%{value}\";\n" + "\"%{key}\" = \"%{value}\";" end def format_comment(definition, lang) - "/* #{definition.comment.gsub('*/', '* /')} */\n" if definition.comment + "\n/* #{definition.comment.gsub('*/', '* /')} */\n" if definition.comment end def format_key(key) diff --git a/lib/twine/formatters/apple_plural.rb b/lib/twine/formatters/apple_plural.rb index c53f02b4..1c1efda4 100644 --- a/lib/twine/formatters/apple_plural.rb +++ b/lib/twine/formatters/apple_plural.rb @@ -28,7 +28,7 @@ def format_header(lang) header = "\n" header += "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>\n" header += "\n" - header += "\n" + header += "\n\n" end def format_section_header(section)