Dim lang As String = "english"
Dim code As String
Dim language As String = lang.ToLowerCase
If(Regex.IsMatch("portuguese",language) = True) Then code = "PT"
If(Regex.IsMatch("english",language) = True) Then code = "EN":Log("EN"):Log(code) 'Prints EN - correct and PT - WRONG
Log(code) 'Prints PT - WRONG
Log(Regex.IsMatch("english",language)) 'Prints True!!! - Correct
Everyone's right... lang is defined as a literal string. BUT, I'm actually atributing to lang the result of a function:
B4X:
Sub GetDefaultLanguage As String
Dim r As Reflector
r.Target = r.RunStaticMethod("java.util.Locale", "getDefault", Null, Null)
Return r.RunMethod("getDisplayName")
End Sub
If I define lang as string = "english" I get good results. But if I give lang the value of GetDefaultLanguage (and then put lang to lower case), I get nothing. Even if the Log() is right (gives the lang as "english..." instead of "English...")
Instead of Return r.RunMethod("getDisplayName")
why don't you use this Return r.RunMethod("getLanguage")
you get directly the two character lower case language code!