[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [torbutton/maint-1.2 3/5] Bug 1911: Fix broken locale useragent string on Debian.
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Thu, 30 Sep 2010 07:44:38 -0700
Subject: Bug 1911: Fix broken locale useragent string on Debian.
Commit: 651be65f349a3ba608a7e8f4385c24d7771bd619
Patch from lunar.
---
src/chrome/content/torbutton.js | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 89c6297..3abea15 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -926,22 +926,38 @@ function torbutton_set_timezone(mode, startup) {
}
}
+function torbutton_get_general_useragent_locale() {
+ try {
+ var locale = m_tb_prefs.getCharPref("general.useragent.locale");
+ if (locale != "chrome://global/locale/intl.properties") {
+ return locale;
+ }
+
+ var bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService);
+ var stringbundle = bundle.createBundle(locale);
+ return stringbundle.GetStringFromName("general.useragent.locale");
+ } catch(err) {
+ torbutton_log(4, "Error while getting general.useragent.locale:" + err);
+ return 'en-US';
+ }
+}
+
function torbutton_set_uagent() {
try {
var torprefs = torbutton_get_prefbranch('extensions.torbutton.');
var lang = new RegExp("LANG", "gm");
var appname = torprefs.getCharPref("appname_override");
var appvers = torprefs.getCharPref("appversion_override");
+ var generalLocale = torbutton_get_general_useragent_locale();
if(torprefs.getBoolPref("spoof_english")) {
appname = appname.replace(lang,
torprefs.getCharPref("spoof_locale"));
appvers = appvers.replace(lang,
torprefs.getCharPref("spoof_locale"));
} else {
- appname = appname.replace(lang,
- m_tb_prefs.getCharPref("general.useragent.locale"));
- appvers = appvers.replace(lang,
- m_tb_prefs.getCharPref("general.useragent.locale"));
+ appname = appname.replace(lang, generalLocale);
+ appvers = appvers.replace(lang, generalLocale);
}
m_tb_prefs.setCharPref("general.appname.override", appname);
@@ -955,8 +971,7 @@ function torbutton_set_uagent() {
agent = agent.replace(lang,
torprefs.getCharPref("spoof_locale"));
} else {
- agent = agent.replace(lang,
- m_tb_prefs.getCharPref("general.useragent.locale"));
+ agent = agent.replace(lang, generalLocale);
}
m_tb_prefs.setCharPref("general.useragent.override", agent);
--
1.7.1