Better handling of language code exceptions

pull/14/head
Sam Bosley 13 years ago
parent 73d1003750
commit a8d0a4fb9d

@ -6,30 +6,26 @@
# platform: 'android', 'ios', or 'web' # platform: 'android', 'ios', or 'web'
# lang: Language code or 'master' # lang: Language code or 'master'
LangException = Struct.new :platform, :platform_code, :getloc_code
LANG_EXCEPTIONS = [
LangException.new(:ios, "zh-Hans", "zh-TW")
LangException.new(:ios, "zh", "zh-CN"),
]
# Converts astrid language codes to GetLocalization language codes (which don't use -r) # Converts astrid language codes to GetLocalization language codes (which don't use -r)
def astrid_code_to_getloc_code(lang, platform) def astrid_code_to_getloc_code(lang, platform)
result = lang.sub("-r", "-") result = lang.sub("-r", "-")
if platform == :ios exception = LANG_EXCEPTIONS.find { |le| le.platform == platform and le.platform_code == lang }
if lang == "zh-Hans" exception ? exception.getloc_code : result
result = "zh-TW"
elsif lang == "zh"
result = "zh-CN"
end
end
result
end end
# Inverse of the above function # Inverse of the above function
def getloc_code_to_astrid_code(lang, platform) def getloc_code_to_astrid_code(lang, platform)
result = lang.sub("-", "-r") result = lang.sub("-", "-r")
if platform == :ios exception = LANG_EXCEPTIONS.find { |le| le.platform == platform and le.getloc_code == lang }
if lang == "zh-CN" exception ? exception.platform_code : result
result = "zh"
elsif lang == "zh-TW"
result = "zh-Hans"
end
end
result
end end
# Uploads files for the specified language to GetLocalization # Uploads files for the specified language to GetLocalization

Loading…
Cancel
Save