I have the following code to find a local 2 letter country code. It works for what I want but crashes when I set the iPad to France. Any suggestions why?
Can you test this in the simulator? or does it always give en_us
Dim country, a As Text
country = Locale.Current.Identifier.ToText
If country.IndexOf("@") > -1 Then
country = country.Left(country.IndexOf("@"))
End If
If country.BeginsWith("zh_CN") or country.BeginsWith("zh-Hans") then
//Chinese (Simplified)
MessageBox("Current Languages and Dictionaries Avaliable are, English, French, Portugese and Spanish")
Elseif country.BeginsWith("zh_TW") or country.BeginsWith("zh-Hant") then
//Chinese (Traditional)
MessageBox("Current Languages and Dictionaries Avaliable are, English, French, Portugese and Spanish")
Elseif country.BeginsWith("zh") then
//Assume it is Chinese (Simplified)
MessageBox("Current Languages and Dictionaries Avaliable are, English, French, Portugese and Spanish")
Elseif country.IndexOf("_") > -1 then
country = country.Left(country.IndexOf("_"))
//Identifier will be the language code
//Note that it isn't necessarly a 2 letter code
//Example: ko-Kore, ckb-Arab, fur-Latn, ms-Arab, fil, ain
'MessageOk("Current Languages and Dictionaries set to",identifier ,"")
Elseif country.length = 2 then
//Identifier is a 2 letter code
a = "Unknown Language" + country
MessageBox(a)
Else
//Raise an exception to treat this special case
a = "I don't know what country you are in?? Please select a different language."
MessageBox(a)
End If
return country