Sub Process_Globals
Private nativeMe As JavaObject
End Sub
Sub Locale(item As String) As String
nativeMe.InitializeContext
Dim id As Int = nativeMe.RunMethod("getResourceId", Array("string", item))
If id > 0 Then
Return nativeMe.RunMethod("GetString", Array(id))
Else
Return item
End If
End Sub
Sub Plural(item As String, count As Int) As String
nativeMe.InitializeContext
Dim id As Int = nativeMe.RunMethod("getResourceId", Array("plurals", item))
If id > 0 Then
Return nativeMe.RunMethod("FormatPlural", Array(id, count))
Else
Return item
End If
End Sub
#if Java
public int getResourceId(String type, String name) {
return BA.applicationContext.getResources().getIdentifier(name, type, BA.packageName);
}
public String FormatPlural(int id, int count) {
return BA.applicationContext.getResources().getQuantityString(id, count, count);
}
public String GetString(int id) {
return BA.applicationContext.getResources().getString(id);
}
#End If