Merge pull request #141 from sebastianludwig/android_output_folders
Properly prefixing Android output path
This commit is contained in:
commit
e690be4eee
2 changed files with 15 additions and 3 deletions
|
@ -7,11 +7,11 @@ module Twine
|
|||
class Android < Abstract
|
||||
include Twine::Placeholders
|
||||
|
||||
LANG_CODES = Hash[
|
||||
'zh' => 'zh-Hans',
|
||||
LANG_MAPPINGS = Hash[
|
||||
'zh-rCN' => 'zh-Hans',
|
||||
'zh-rHK' => 'zh-Hant',
|
||||
'en-rGB' => 'en-UK',
|
||||
'zh' => 'zh-Hans',
|
||||
'in' => 'id',
|
||||
'nb' => 'no'
|
||||
# TODO: spanish
|
||||
|
@ -44,7 +44,7 @@ module Twine
|
|||
match = /^values-([a-z]{2}(-r[a-z]{2})?)$/i.match(segment)
|
||||
if match
|
||||
lang = match[1]
|
||||
lang = LANG_CODES.fetch(lang, lang)
|
||||
lang = LANG_MAPPINGS.fetch(lang, lang)
|
||||
lang.sub!('-r', '-')
|
||||
return lang
|
||||
end
|
||||
|
@ -54,6 +54,10 @@ module Twine
|
|||
return
|
||||
end
|
||||
|
||||
def output_path_for_language(lang)
|
||||
"values-" + (LANG_MAPPINGS.key(lang) || lang)
|
||||
end
|
||||
|
||||
def set_translation_for_key(key, lang, value)
|
||||
value = CGI.unescapeHTML(value)
|
||||
value.gsub!('\\\'', '\'')
|
||||
|
|
|
@ -116,6 +116,14 @@ class TestAndroidFormatter < FormatterTest
|
|||
def test_does_not_deduct_language_from_device_capability_resource_folder
|
||||
assert_nil @formatter.determine_language_given_path('res/values-w820dp')
|
||||
end
|
||||
|
||||
def test_output_path_is_prefixed
|
||||
assert_equal 'values-en', @formatter.output_path_for_language('en')
|
||||
end
|
||||
|
||||
def test_output_path_language_mappings
|
||||
assert_equal 'values-zh-rCN', @formatter.output_path_for_language('zh-Hans')
|
||||
end
|
||||
end
|
||||
|
||||
class TestAppleFormatter < FormatterTest
|
||||
|
|
Reference in a new issue