Skip to content

Commit

Permalink
Tune whitespacing settings to be compatible with Weblate
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Tsisyk <[email protected]>
  • Loading branch information
rtsisyk committed Nov 2, 2021
1 parent 649967b commit 6a4d83d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/twine/formatters/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) }
Expand Down
18 changes: 9 additions & 9 deletions lib/twine/formatters/android.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,33 @@ def read(io, lang)
end

def format_header(lang)
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Android Strings File -->\n<!-- Generated by Twine #{Twine::VERSION} -->\n<!-- Language: #{lang} -->"
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Android Strings File --><!-- Generated by Twine #{Twine::VERSION} --><!-- Language: #{lang} -->"
end

def format_sections(twine_file, lang)
result = '<resources>'
result = "<resources>\n"

result += super + "\n"

result += "</resources>\n"
result += "</resources>"
end

def format_section_header(section)
"\t<!-- SECTION: #{section.name} -->"
" <!-- SECTION: #{section.name} -->"
end

def format_comment(definition, lang)
"\t<!-- #{definition.comment.gsub('--', '—')} -->\n" if definition.comment
" <!-- #{definition.comment.gsub('--', '—')} -->\n" if definition.comment
end

def key_value_pattern
"\t<string name=\"%{key}\">%{value}</string>"
" <string name=\"%{key}\">%{value}</string>"
end

def format_plural_keys(key, plural_hash)
result = "\t<plurals name=\"#{key}\">\n"
result += plural_hash.map{|quantity,value| "\t#{' ' * 2}<item quantity=\"#{quantity}\">#{escape_value(value)}</item>"}.join("\n")
result += "\n\t</plurals>"
result = " <plurals name=\"#{key}\">\n"
result += plural_hash.map{|quantity,value| " #{' ' * 4}<item quantity=\"#{quantity}\">#{escape_value(value)}</item>"}.join("\n")
result += "\n </plurals>"
end

def gsub_unless(text, pattern, replacement)
Expand Down
4 changes: 2 additions & 2 deletions lib/twine/formatters/apple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def read(io, lang)
end

def format_header(lang)
"/**\n * Apple Strings File\n * Generated by Twine #{Twine::VERSION}\n * Language: #{lang}\n */"
"/**\n * Apple Strings File\n * Generated by Twine #{Twine::VERSION}\n * Language: #{lang}\n */\n"
end

def format_section_header(section)
"/********** #{section.name} **********/\n"
"\n/********** #{section.name} **********/\n"
end

def key_value_pattern
Expand Down
2 changes: 1 addition & 1 deletion lib/twine/formatters/apple_plural.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def format_header(lang)
header = "<!--\n * Apple Stringsdict File\n * Generated by Twine #{Twine::VERSION}\n * Language: #{lang} -->\n"
header += "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>\n"
header += "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
header += "<plist version=\"1.0\">\n<dict>"
header += "<plist version=\"1.0\">\n<dict>\n"
end

def format_section_header(section)
Expand Down

0 comments on commit 6a4d83d

Please sign in to comment.