First of all let me say I don't know much about the subject, so I may inadvertently be a bit blunt.
I'm trying to extract language and country from the locale code, in order to create custom form for my clients.
List of locales from : List of All Locales and Their Short Codes?
My code so far :
# Unless specified, simplified chinese for RPC and Singapour, traditional for HK and Macao SAR, ROC
# zh = simplified, ch = traditional
match locale:
case "zh_CN", "zh_SG":
language = "ch"
country = locale[3:]
case "zh_Hans":
language = "zh"
country = "CN"
case 'zh_Hans_CN', 'zh_Hans_HK', 'zh_Hans_MO', 'zh_Hans_SG':
language = "zh"
country = locale[8:]
case "zh_Hant":
language = "ch"
country = "CN"
case 'zh_Hant_HK', 'zh_Hant_MO', 'zh_Hant_TW':
language = "ch"
country = locale[8:]
Is this acceptable ?