Compare commits
17 commits
organicmap
...
weblate_an
Author | SHA1 | Date | |
---|---|---|---|
|
5751945f1d | ||
|
960715c45a | ||
|
a04e1ba7d6 | ||
|
1552401c88 | ||
|
698c63139c | ||
|
aa853e5506 | ||
|
22071efd3c | ||
|
5ea7bdb5d0 | ||
|
3131556bb5 | ||
|
20a57301f7 | ||
|
b79bbc37a6 | ||
|
9c226e0d30 | ||
|
28dc23db64 | ||
|
df14ff81a9 | ||
|
44e94015df | ||
|
22313c25aa | ||
|
92b1d9ebf7 |
6 changed files with 56 additions and 31 deletions
|
@ -103,7 +103,7 @@ module Twine
|
|||
|
||||
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 @@ module Twine
|
|||
|
||||
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) }
|
||||
|
|
|
@ -96,11 +96,11 @@ module Twine
|
|||
end
|
||||
|
||||
def format_header(lang)
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
||||
end
|
||||
|
||||
def format_sections(twine_file, lang)
|
||||
result = '<resources>'
|
||||
result = "<resources>\n"
|
||||
|
||||
result += super + "\n"
|
||||
|
||||
|
@ -196,6 +196,14 @@ module Twine
|
|||
value.gsub(/\A *| *\z/) { |spaces| '\u0020' * spaces.length }
|
||||
end
|
||||
|
||||
def should_include_definition(definition, lang)
|
||||
if definition.is_plural?
|
||||
return !definition.plural_translation_for_lang(lang).nil?
|
||||
else
|
||||
return !definition.translation_for_lang(lang).nil?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -65,16 +65,25 @@ module Twine
|
|||
end
|
||||
end
|
||||
|
||||
def format_footer(lang)
|
||||
"\n"
|
||||
end
|
||||
|
||||
def format_file(lang)
|
||||
result = super
|
||||
result += format_footer(lang)
|
||||
end
|
||||
|
||||
def format_section_header(section)
|
||||
"/********** #{section.name} **********/\n"
|
||||
"\n\n/********** #{section.name} **********/"
|
||||
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)
|
||||
|
|
|
@ -18,12 +18,7 @@ module Twine
|
|||
end
|
||||
|
||||
def format_footer(lang)
|
||||
footer = "</dict>\n</plist>"
|
||||
end
|
||||
|
||||
def format_file(lang)
|
||||
result = super
|
||||
result += format_footer(lang)
|
||||
footer = "\n</dict>\n</plist>\n"
|
||||
end
|
||||
|
||||
def format_header(lang)
|
||||
|
@ -33,7 +28,6 @@ module Twine
|
|||
end
|
||||
|
||||
def format_section_header(section)
|
||||
"<!-- ********** #{section.name} **********/ -->\n"
|
||||
end
|
||||
|
||||
def format_plural_keys(key, plural_hash)
|
||||
|
@ -51,7 +45,7 @@ module Twine
|
|||
result += plural_hash.map{|quantity,value| "\t\t\t<key>#{quantity}</key>\n\t\t\t<string>#{convert_placeholders_from_android_to_twine(value)}</string>"}.join("\n")
|
||||
result += "\n"
|
||||
result += "\t\t</dict>\n"
|
||||
result += "\t</dict>\n"
|
||||
result += "\t</dict>"
|
||||
end
|
||||
|
||||
def format_comment(definition, lang)
|
||||
|
|
|
@ -50,8 +50,8 @@ module Twine
|
|||
|
||||
if definition.is_plural?
|
||||
# If definition is plural, but no translation found -> create
|
||||
# Then check 'other' key
|
||||
if !(new_definition.plural_translations[language] ||= {}).key? 'other'
|
||||
# and add 'other' key
|
||||
if (new_definition.plural_translations[language] ||= {}).empty?
|
||||
new_definition.plural_translations[language]['other'] = value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -213,25 +213,34 @@ module Twine
|
|||
f.puts "[[#{section.name}]]"
|
||||
|
||||
section.definitions.each do |definition|
|
||||
f.puts "\t[#{definition.key}]"
|
||||
f.puts "\n#{space(2)}[#{definition.key}]"
|
||||
|
||||
if definition.raw_comment and definition.raw_comment.length > 0
|
||||
f.puts "#{space(4)}comment = #{definition.raw_comment}"
|
||||
end
|
||||
if definition.tags && definition.tags.length > 0
|
||||
tag_str = definition.tags.join(',')
|
||||
f.puts "#{space(4)}tags = #{tag_str}"
|
||||
end
|
||||
if definition.reference_key
|
||||
f.puts "#{space(4)}ref = #{definition.reference_key}"
|
||||
end
|
||||
|
||||
value = write_value(definition, dev_lang, f)
|
||||
if !value && !definition.reference_key
|
||||
Twine::stdout.puts "WARNING: #{definition.key} does not exist in developer language '#{dev_lang}'"
|
||||
end
|
||||
|
||||
if definition.reference_key
|
||||
f.puts "\t\tref = #{definition.reference_key}"
|
||||
end
|
||||
if definition.tags && definition.tags.length > 0
|
||||
tag_str = definition.tags.join(',')
|
||||
f.puts "\t\ttags = #{tag_str}"
|
||||
end
|
||||
if definition.raw_comment and definition.raw_comment.length > 0
|
||||
f.puts "\t\tcomment = #{definition.raw_comment}"
|
||||
end
|
||||
|
||||
@language_codes[1..-1].each do |lang|
|
||||
write_value(definition, lang, f)
|
||||
if lang =~ /^#{dev_lang}/
|
||||
write_value(definition, lang, f)
|
||||
end
|
||||
end
|
||||
|
||||
@language_codes[1..-1].each do |lang|
|
||||
if not lang =~ /^#{dev_lang}/
|
||||
write_value(definition, lang, f)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -248,9 +257,14 @@ module Twine
|
|||
value = '`' + value + '`'
|
||||
end
|
||||
|
||||
file.puts "\t\t#{language} = #{value}"
|
||||
file.puts "#{space(4)}#{language} = #{value}"
|
||||
return value
|
||||
end
|
||||
|
||||
def space(level)
|
||||
' ' * level
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue