我已經用hindi(即系統默認語言以外)和使用google的api(PlaceAutocomplete,GoogleSignIn)設置了我的應用程序的默認語言。如何在應用程序的默認語言中設置google api對話框的文本
兩者都顯示英文(系統默認語言)的文本,而不是印地文或任何應用程序的默認語言。
有什麼辦法,我可以強制它們加載應用程序的默認語言,或者我可以傳遞我的默認應用程序的語言。
謝謝。這將是非常有幫助的。尋找任何更新。
我已經用hindi(即系統默認語言以外)和使用google的api(PlaceAutocomplete,GoogleSignIn)設置了我的應用程序的默認語言。如何在應用程序的默認語言中設置google api對話框的文本
兩者都顯示英文(系統默認語言)的文本,而不是印地文或任何應用程序的默認語言。
有什麼辦法,我可以強制它們加載應用程序的默認語言,或者我可以傳遞我的默認應用程序的語言。
謝謝。這將是非常有幫助的。尋找任何更新。
不能設置你想從區域設置可以設置默認language.By其英文如果更改然後讓你像this.Please檢查下面的代碼給多個language.Then系統默認門語言。 。
選擇語言並保存語言的價值SharedPreferences。每當開始應用程序檢查語言首選項的值,然後讓它選擇它們。
確保每個字符串都應該以此形式添加到值文件夾中。
對於默認的英語,然後把所有的字符串內值。對於印地文,你需要設置值喜 .Same的事情發生了其他語言把他們串國家code.For國家代碼here去。
SharedPreferences sharedPreferences = getSharedPreferences(Common.MYPREFERENCE_LANGUAGE, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
if (parent.getSelectedItem().equals("English")) {
Utils.updateLanguage(activity, "en");
editor.putString("language", "en");
} else {
Utils.updateLanguage(activity, "hi");
editor.putString("language", "hi");
}
editor.apply();
公共靜態無效updateLanguage(上下文的背景下,字符串郎){
String mlanguage = getlanguage(lang);
PurplkiteLogs.logError("", " language update " + mlanguage);
Locale locale = null;
Configuration config;
try {
if (mlanguage.equals("en")) {
locale = Locale.ENGLISH;
} else if (mlanguage.equals("hi")) {
locale = setLocale(context,"hi");
} else {
locale = new Locale(mlanguage);
}
Locale.setDefault(locale);
config = new Configuration();
config.locale = locale;
context.getResources().updateConfiguration(config,
context.getResources().getDisplayMetrics());
} catch (Exception e) {
} finally {
mlanguage = null;
config = null;
locale = null;
context = null;
}
}
private static String getlanguage(String lang) {
String mlang = null;
if (lang != null) {
if (lang.trim().equalsIgnoreCase("hi")) {
mlang = "hi";
} else {
mlang = "en";
}
}
return mlang;
}
public static Locale setLocale(Context context ,String lang) {
Locale myLocale = new Locale(lang);
Resources res = context.getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
return conf.locale;
}
感謝,希望這將幫助你解決你的問題,並清除概念。
看起來像這可能不可能與本地API,目前:http://stackoverflow.com/questions/34321356/how-to-set-language-for-google-place-details-result-in-android – Demonsoul