Compare commits

..

17 commits

Author SHA1 Message Date
Dwayne Bailey
5751945f1d Keep derivatives of dev languahe close to the top
allow
en
en-GB

before alphabetical sorting

Aligns with existing and is more logical
2024-09-18 21:19:28 +01:00
Dwayne Bailey
960715c45a Insert space before each translation block 2024-09-18 21:19:28 +01:00
Dwayne Bailey
a04e1ba7d6 Order meta data as comment, tags, ref
OrganicMaps:
comment =
tags =
ref =
dev-LANG =
other-LANG =

Twine original:
dev-LANG =
ref =
tags =
comment =
other-LANG =

fix
2024-09-18 21:19:08 +01:00
Dwayne Bailey
1552401c88 Output developer language after meta tags
This aligns with current OrganicMaps structure of:

comment =
tag =
en =
2024-09-18 19:36:24 +01:00
Dwayne Bailey
698c63139c Use space indentation for Twine file 2024-09-18 19:33:02 +01:00
Dwayne Bailey
aa853e5506 Ensure plurals are output even if they don't appear magically in normal
transliatont
2024-09-18 09:52:10 +01:00
Dwayne Bailey
22071efd3c Don't force the creation of 'other' form 2024-09-18 09:52:10 +01:00
Dwayne Bailey
5ea7bdb5d0 Don't force newlines before sections 2024-09-18 09:52:10 +01:00
Dwayne Bailey
3131556bb5 Add blank before a comment in Apple files 2024-09-18 09:52:10 +01:00
Dwayne Bailey
20a57301f7 Add footer for newlines in Apple 2024-09-18 09:52:10 +01:00
Dwayne Bailey
b79bbc37a6 event extra newlines after setion header 2024-09-18 09:52:10 +01:00
Dwayne Bailey
9c226e0d30 Ensure two blank lines before section header 2024-09-18 09:52:10 +01:00
Dwayne Bailey
28dc23db64 Remove blank lines between Apple strings 2024-09-18 09:52:10 +01:00
Dwayne Bailey
df14ff81a9 Don't format abstrat to break between headers 2024-09-18 09:52:10 +01:00
Dwayne Bailey
44e94015df Don't split sections with space 2024-09-18 09:52:10 +01:00
Dwayne Bailey
22313c25aa Remove section coments from iPhone stringdict 2024-09-18 09:52:10 +01:00
Dwayne Bailey
92b1d9ebf7 Add EOF newline for iPhone plurals 2024-09-18 09:52:10 +01:00
6 changed files with 50 additions and 30 deletions

View file

@ -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) }

View file

@ -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

View file

@ -65,13 +65,17 @@ module Twine
end
end
def format_footer(lang)
"\n"
end
def format_file(lang)
result = super
result += "\n"
result += format_footer(lang)
end
def format_section_header(section)
"\n/********** #{section.name} **********/\n"
"\n\n/********** #{section.name} **********/"
end
def key_value_pattern

View file

@ -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)

View file

@ -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

View file

@ -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