diff --git a/java/res/xml-de/kbd_qwerty.xml b/java/res/xml-de/kbd_qwerty.xml
index 6b5c223916f2e3681692e7b12f169b433433592d..e6569667d87c21d74de3f11ff078fe76bc29c207 100644
--- a/java/res/xml-de/kbd_qwerty.xml
+++ b/java/res/xml-de/kbd_qwerty.xml
@@ -28,7 +28,7 @@
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
     latin:maxPopupKeyboardColumn="@integer/config_max_popup_keyboard_column"
-    latin:keyboardLocale="de"
+    latin:keyboardLocale="de_DE"
 >
     <include
         latin:keyboardLayout="@xml/kbd_qwertz_rows" />
diff --git a/java/res/xml-fr/kbd_qwerty.xml b/java/res/xml-fr/kbd_qwerty.xml
index e4b73bf21f149966b8b9737c32e8fdb2f7270074..2f8e67bb187550631f1f7a029bdf6b1e7d1d518c 100644
--- a/java/res/xml-fr/kbd_qwerty.xml
+++ b/java/res/xml-fr/kbd_qwerty.xml
@@ -28,7 +28,7 @@
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
     latin:maxPopupKeyboardColumn="@integer/config_max_popup_keyboard_column"
-    latin:keyboardLocale="fr"
+    latin:keyboardLocale="fr_FR"
 >
     <include
         latin:keyboardLayout="@xml/kbd_azerty_rows" />
diff --git a/java/res/xml-ru/kbd_qwerty.xml b/java/res/xml-ru/kbd_qwerty.xml
index 065cf3afc3ea9f9ce877119fb5b99e4e5ae4d48e..e5aea581eb512f7751997bf01143f01bbb1bdf18 100644
--- a/java/res/xml-ru/kbd_qwerty.xml
+++ b/java/res/xml-ru/kbd_qwerty.xml
@@ -27,7 +27,7 @@
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
     latin:maxPopupKeyboardColumn="@integer/config_max_popup_keyboard_column"
-    latin:keyboardLocale="ru"
+    latin:keyboardLocale="ru_RU"
 >
     <include
         latin:keyboardLayout="@xml/kbd_ru_rows" />
diff --git a/java/res/xml/kbd_qwerty.xml b/java/res/xml/kbd_qwerty.xml
index 6bf6b781de51b30f056ad37271f25e633831fdbb..a4251c0bdcc3328e60c96490044b94e743860689 100644
--- a/java/res/xml/kbd_qwerty.xml
+++ b/java/res/xml/kbd_qwerty.xml
@@ -28,7 +28,7 @@
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
     latin:maxPopupKeyboardColumn="@integer/config_max_popup_keyboard_column"
-    latin:keyboardLocale="en"
+    latin:keyboardLocale="en_GB,en_US"
 >
     <include
         latin:keyboardLayout="@xml/kbd_qwerty_rows" />
diff --git a/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java b/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
index 6c6960cc484267022762338e4c280a28ce13c87e..ce576d0cca696200f32152e672bba5eae217ce0a 100644
--- a/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
+++ b/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
@@ -43,13 +43,15 @@ import java.io.IOException;
 import java.text.Collator;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Locale;
 
 public class InputLanguageSelection extends PreferenceActivity {
 
     private SharedPreferences mPrefs;
     private String mSelectedLanguages;
-    private ArrayList<Loc> mAvailableLanguages = new ArrayList<Loc>();
+    private HashMap<CheckBoxPreference, Locale> mLocaleMap =
+            new HashMap<CheckBoxPreference, Locale>();
 
     private static class Loc implements Comparable<Object> {
         private static Collator sCollator = Collator.getInstance();
@@ -85,14 +87,17 @@ public class InputLanguageSelection extends PreferenceActivity {
         mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
         mSelectedLanguages = mPrefs.getString(Settings.PREF_SELECTED_LANGUAGES, "");
         String[] languageList = mSelectedLanguages.split(",");
-        mAvailableLanguages = getUniqueLocales();
+        ArrayList<Loc> availableLanguages = getUniqueLocales();
         PreferenceGroup parent = getPreferenceScreen();
-        for (int i = 0; i < mAvailableLanguages.size(); i++) {
-            Locale locale = mAvailableLanguages.get(i).mLocale;
+        for (int i = 0; i < availableLanguages.size(); i++) {
+            Locale locale = availableLanguages.get(i).mLocale;
             final Pair<Boolean, Boolean> hasDictionaryOrLayout = hasDictionaryOrLayout(locale);
             final boolean hasDictionary = hasDictionaryOrLayout.first;
             final boolean hasLayout = hasDictionaryOrLayout.second;
-            if (!hasDictionary && !hasLayout) {
+            // Add this locale to the supported list if:
+            // 1) this locale has a layout/ 2) this locale has a dictionary and the length
+            // of the locale is equal to or larger than 5.
+            if (!hasLayout && !(hasDictionary && locale.toString().length() >= 5)) {
                 continue;
             }
             CheckBoxPreference pref = new CheckBoxPreference(this);
@@ -102,6 +107,7 @@ public class InputLanguageSelection extends PreferenceActivity {
             if (hasDictionary) {
                 pref.setSummary(R.string.has_dictionary);
             }
+            mLocaleMap.put(pref, locale);
             parent.addPreference(pref);
         }
     }
@@ -135,11 +141,16 @@ public class InputLanguageSelection extends PreferenceActivity {
             }
             bd.close();
 
-            final String countryCode = locale.getLanguage();
-            final String layoutCountryCode = KeyboardParser.parseKeyboardLocale(
-                    this, R.xml.kbd_qwerty);
-            if (!TextUtils.isEmpty(countryCode) && !TextUtils.isEmpty(layoutCountryCode)) {
-                hasLayout = countryCode.subSequence(0, 2).equals(layoutCountryCode.substring(0, 2));
+            final String localeStr = locale.toString();
+            final String[] layoutCountryCodes = KeyboardParser.parseKeyboardLocale(
+                    this, R.xml.kbd_qwerty).split(",", -1);
+            if (!TextUtils.isEmpty(localeStr) && layoutCountryCodes.length > 0) {
+                for (String s : layoutCountryCodes) {
+                    if (s.equals(localeStr)) {
+                        hasLayout = true;
+                        break;
+                    }
+                }
             }
         } catch (XmlPullParserException e) {
         } catch (IOException e) {
@@ -170,8 +181,7 @@ public class InputLanguageSelection extends PreferenceActivity {
         for (int i = 0; i < count; i++) {
             CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
             if (pref.isChecked()) {
-                Locale locale = mAvailableLanguages.get(i).mLocale;
-                checkedLanguages += get5Code(locale) + ",";
+                checkedLanguages += get5Code(mLocaleMap.get(pref)) + ",";
             }
         }
         if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null