Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune whitespacing settings to be compatible with Weblate #2

Open
wants to merge 1 commit into
base: organicmaps
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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} -->"
Copy link
Member

@biodranik biodranik Nov 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

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
6 changes: 3 additions & 3 deletions lib/twine/formatters/apple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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