Permalink
Browse files

Merge pull request #193 from yuvipanda/bug35650

Make default language for search be the system's default locale
  • Loading branch information...
2 parents b8ded83 + 1f77f87 commit 0163b677a156ae58a3078fe4a5076a26f597816f @jdlrobson jdlrobson committed Apr 3, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/org/wikipedia/SearchSuggestionsProvider.java
@@ -1,6 +1,7 @@
package org.wikipedia;
import java.net.URLEncoder;
+import java.util.Locale;
import org.json.JSONArray;
@@ -29,12 +30,23 @@ public boolean onCreate() {
return true;
}
+ private String getDefaultLanguage() {
+ // Returns default language to be used.
+ // Takes default system language, and does minor fixes so that they match the languages wikipedia uses
+ String locale = Locale.getDefault().getLanguage();
+ String language = locale.split("-")[0];
+ if(language == "iw") {
+ // Java (and Android) think Hebrew is iw, while it actually is he
+ language = "he";
+ }
+ return language;
+ }
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
String query = uri.getLastPathSegment();
try {
SharedPreferences settings = this.getContext().getSharedPreferences(PreferencesPlugin.PREFS_NAME, Context.MODE_PRIVATE);
- String lang = settings.getString("language", "en");
+ String lang = settings.getString("language", getDefaultLanguage());
String[] columnNames = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_INTENT_DATA };
MatrixCursor cursor = new MatrixCursor(columnNames);
@@ -68,4 +80,4 @@ public int update(Uri uri, ContentValues values, String selection, String[] sele
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
-}
+}

0 comments on commit 0163b67

Please sign in to comment.