using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
public class CountryAndLanguage
{
static public string GetLanguage()
{
if (Application.isEditor)
{
Debug.LogError("systemLanguage:" + Application.systemLanguage.ToString());
return Application.systemLanguage.ToString();
}
AndroidJavaClass unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject _unityContext = unityClass.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject locale = _unityContext.Call<AndroidJavaObject>("getResources").Call<AndroidJavaObject>("getConfiguration").Get<AndroidJavaObject>("locale");
string systemLanguage = locale.Call<string>("getLanguage");
Debug.LogError("systemLanguage:" + systemLanguage);
return systemLanguage;
}
static public string GetCountry()
{
if (Application.isEditor)
{
Debug.LogError("country:" + RegionInfo.CurrentRegion.Name);
return RegionInfo.CurrentRegion.ISOCurrencySymbol;
}
AndroidJavaClass unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject _unityContext = unityClass.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject locale = _unityContext.Call<AndroidJavaObject>("getResources").Call<AndroidJavaObject>("getConfiguration").Get<AndroidJavaObject>("locale");
string country = locale.Call<string>("getCountry");
Debug.LogError("country:" + country);
return country;
}
}