diff options
author | Bill Napier <napier@google.com> | 2009-05-05 13:19:58 -0700 |
---|---|---|
committer | Bill Napier <napier@google.com> | 2009-05-11 10:18:51 -0700 |
commit | 506f3c92a41db1d80bfcdd8bbf1cca93b3733b6c (patch) | |
tree | 1fb0f7753b1044f3849751806c0f88f017ac33da | |
parent | af0a721284a9de7c44522214bdca04076f383b77 (diff) | |
download | GoogleSearch-506f3c92a41db1d80bfcdd8bbf1cca93b3733b6c.tar.gz |
Update google_search_base for chinese language.
Changed default search base for china to be www.google.cn and changed the language param.
-rw-r--r-- | res/values-zh-rCN/strings.xml | 5 | ||||
-rw-r--r-- | src/com/android/googlesearch/SuggestionProvider.java | 20 |
2 files changed, 23 insertions, 2 deletions
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 43d39d3..ff937c7 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -16,4 +16,9 @@ <resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="search_hint">"Google 搜索"</string> + + <!-- China has a different url than the standard suggest url. --> + <!-- Do not translate. This string is an internal URI, not seen in the UI. --> + <string name="google_search_base" translatable="false"> + http://www.google.cn/complete/search?hl=%1$s&gl=%2$s&</string> </resources> diff --git a/src/com/android/googlesearch/SuggestionProvider.java b/src/com/android/googlesearch/SuggestionProvider.java index 416f9d0..141aaed 100644 --- a/src/com/android/googlesearch/SuggestionProvider.java +++ b/src/com/android/googlesearch/SuggestionProvider.java @@ -122,9 +122,25 @@ public class SuggestionProvider extends ContentProvider { // resource strings, which are stored in mcc-specific xml files.) if (mSuggestUri == null) { Locale l = Locale.getDefault(); + String language = l.getLanguage(); + String country = l.getCountry().toLowerCase(); + // Chinese and Portuguese have two langauge variants. + if ("zh".equals(language)) { + if ("cn".equals(country)) { + language = "zh-CN"; + } else if ("tw".equals(country)) { + language = "zh-TW"; + } + } else if ("pt".equals(language)) { + if ("br".equals(country)) { + language = "pt-BR"; + } else if ("pt".equals(country)) { + language = "pt-PT"; + } + } mSuggestUri = getContext().getResources().getString(R.string.google_search_base, - l.getLanguage(), - l.getCountry().toLowerCase()) + language, + country) + "json=true&q="; } |