2016-09-12 10 views
13

(すなわち。システムのデフォルトの言語以外の)とGoogleのAPI(PlaceAutocomplete、GoogleSignIn)を使用して、GoogleのAPIのダイアログのテキストを設定する方法。アプリケーションのデフォルト言語私はヒンディー語で自分のアプリケーションのデフォルト言語を設定している

の両方が英語(システムのデフォルト言語)ではなく、ヒンディー語のテキストを示すか、どんなアプリケーションのデフォルト言語されています。

、私は、アプリケーションのデフォルト言語でロードするためにそれらを強制することができますか私は、デフォルトのアプリケーションの言語を渡すことができますどのような方法があります。

ありがとうございました。それは本当に役立つだろう。更新を探しています。

+1

は現在、ネイティブのAPIでできないことがあり、次のようになりますhttp://stackoverflow.com/questions/34321356/how-to-set-language-for-google-place-details-result-in-android – Demonsoul

答えて

-1

複数の言語を指定したい場合は、ロケールから言語を設定することができます。変更した場合のデフォルトは英語です。このようにしてください。以下のコードを確認してください。

言語の選択と値の保存SharedPreferences。開始時にいつでもアプリケーションが言語設定の値を確認してから、それらを選択します。

は、すべての文字列は、この形式で値フォルダに追加する必要があることを確認してください。デフォルトの英語

その後、 .FORあなたは値-HIは .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(コンテキストコンテキスト、文字列のlang){

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; 
} 

おかげで、希望は、これはあなたの問題を解決するために、あなたを助け、あなたの概念をクリアします。

+0

あなたは明らかに私の質問を取得できませんでした。私はすでにこれらをしています。 Googleアプリの言語に基づいてこれらのGoogle APIをローカライズする方法を知っておく必要があります。 – UMESH0492

+0

はいこれはできません – Saveen

関連する問題