don't force default into strings.xml; let Android OS handle fallback
This commit is contained in:
parent
828aac3b37
commit
34f7ff8c9c
1 changed files with 4 additions and 7 deletions
|
@ -12,9 +12,7 @@ module Twine
|
|||
'zh' => 'zh-Hans',
|
||||
'zh-rCN' => 'zh-Hans',
|
||||
'zh-rHK' => 'zh-Hant',
|
||||
'zh-rTW' => 'zh-TW',
|
||||
'en-rGB' => 'en-UK',
|
||||
'fr-rCA' => 'fr-CA',
|
||||
'in' => 'id',
|
||||
'nb' => 'no'
|
||||
# TODO: spanish
|
||||
|
@ -69,9 +67,9 @@ module Twine
|
|||
end
|
||||
|
||||
def write_file(path, lang)
|
||||
default_lang = [@strings.language_codes[0]]
|
||||
default_lang = nil
|
||||
if DEFAULT_LANG_CODES.has_key?(lang)
|
||||
default_lang.insert(0, DEFAULT_LANG_CODES[lang])
|
||||
default_lang = DEFAULT_LANG_CODES[lang]
|
||||
end
|
||||
File.open(path, 'w:UTF-8') do |f|
|
||||
f.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Android Strings File -->\n<!-- Generated by Twine -->\n<!-- Language: #{lang} -->"
|
||||
|
@ -92,9 +90,8 @@ module Twine
|
|||
key = row.key
|
||||
|
||||
value = row.translated_string_for_lang(lang, default_lang)
|
||||
value = String.new(value) # use a copy to prevent modifying the original
|
||||
if value
|
||||
# if values is nil, there was no default, so let Android handle the defaulting
|
||||
if value # if values is nil, there was no appropriate translation, so let Android handle the defaulting
|
||||
value = String.new(value) # use a copy to prevent modifying the original
|
||||
|
||||
# Android enforces the following rules on the values
|
||||
# 1) apostrophes and quotes must be escaped with a backslash
|
||||
|
|
Reference in a new issue