From e62b99303fcd5490d8712d82da79ee30af1be4a3 Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Wed, 26 Jul 2006 01:19:42 +0000 Subject: [PATCH] Bug 323798: Keyword URL Needs to be localized, r=axel, sr=bzbarsky --- browser/app/profile/firefox.js | 2 +- .../chrome/browser-region/region.properties | 3 +++ docshell/base/nsDefaultURIFixup.cpp | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 780f5ff864c..7ca92ef95db 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -161,7 +161,7 @@ pref("xpinstall.whitelist.add", "update.mozilla.org"); pref("xpinstall.whitelist.add.103", "addons.mozilla.org"); pref("keyword.enabled", true); -pref("keyword.URL", "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q="); +pref("keyword.URL", "chrome://browser-region/locale/region.properties"); pref("general.useragent.locale", "@AB_CD@"); pref("general.skins.selectedSkin", "classic/1.0"); diff --git a/browser/locales/en-US/chrome/browser-region/region.properties b/browser/locales/en-US/chrome/browser-region/region.properties index d15d0170da4..452eb2f1838 100644 --- a/browser/locales/en-US/chrome/browser-region/region.properties +++ b/browser/locales/en-US/chrome/browser-region/region.properties @@ -16,3 +16,6 @@ startup.homepage_welcome_url=http://www.mozilla.com/firefox/central # This is the fallback URL for release notes. Do not change this # unless you are providing localized release notes! app.update.url.details=http://www.mozilla.com/firefox/releases/ + +# Keyword URL (for location bar searches) +keyword.URL=http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q= diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp index 2adbfc7eb8f..bf6806a6b92 100644 --- a/docshell/base/nsDefaultURIFixup.cpp +++ b/docshell/base/nsDefaultURIFixup.cpp @@ -45,6 +45,7 @@ #include "nsCRT.h" #include "nsIPrefService.h" +#include "nsIPrefLocalizedString.h" #include "nsIPlatformCharset.h" #include "nsILocalFile.h" @@ -373,7 +374,20 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword, NS_ENSURE_STATE(mPrefBranch); nsXPIDLCString url; - mPrefBranch->GetCharPref("keyword.URL", getter_Copies(url)); + nsCOMPtr keywordURL; + mPrefBranch->GetComplexValue("keyword.URL", + NS_GET_IID(nsIPrefLocalizedString), + getter_AddRefs(keywordURL)); + + if (keywordURL) { + nsXPIDLString wurl; + keywordURL->GetData(getter_Copies(wurl)); + CopyUTF16toUTF8(wurl, url); + } else { + // Fall back to a non-localized pref, for backwards compat + mPrefBranch->GetCharPref("keyword.URL", getter_Copies(url)); + } + // if we can't find a keyword.URL keywords won't work. if (url.IsEmpty()) return NS_ERROR_NOT_AVAILABLE;