Skip to content

Commit

Permalink
Merge pull request #193 from yuvipanda/bug35650
Browse files Browse the repository at this point in the history
Make default language for search be the system's default locale
  • Loading branch information
jdlrobson committed Apr 3, 2012
2 parents b8ded83 + 1f77f87 commit 0163b67
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/org/wikipedia/SearchSuggestionsProvider.java
@@ -1,6 +1,7 @@
package org.wikipedia;

import java.net.URLEncoder;
import java.util.Locale;

import org.json.JSONArray;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.