зеркало из https://github.com/mozilla/gecko-dev.git
Camino only - Bug 331576: Determine locale of UA string dynamically. Also fixes 335026 and 336061. Patch by mento <mark@moxienet.com>. r=hwaara sr=pink
This commit is contained in:
Родитель
26647e61f2
Коммит
d478630765
|
@ -80,6 +80,8 @@ extern NSString* const kPrefChangedPrefNameUserInfoKey; // NSString
|
||||||
- (void)setPref:(const char*)prefName toInt:(int)value;
|
- (void)setPref:(const char*)prefName toInt:(int)value;
|
||||||
- (void)setPref:(const char*)prefName toBoolean:(BOOL)value;
|
- (void)setPref:(const char*)prefName toBoolean:(BOOL)value;
|
||||||
|
|
||||||
|
- (void)clearPref:(const char*)prefName;
|
||||||
|
|
||||||
// the path to the user profile's root folder, used by camino 0.8+
|
// the path to the user profile's root folder, used by camino 0.8+
|
||||||
- (NSString*)profilePath;
|
- (NSString*)profilePath;
|
||||||
|
|
||||||
|
|
|
@ -763,11 +763,45 @@ static BOOL gMadePrefManager;
|
||||||
|
|
||||||
// If we understood all the languages in the list set the accept-language header.
|
// If we understood all the languages in the list set the accept-language header.
|
||||||
// Note that necko will determine quality factors itself.
|
// Note that necko will determine quality factors itself.
|
||||||
// If we don't set this we'll fall back to the "en-us, en" default from all-camino.js
|
|
||||||
if (languagesOkaySoFar && [acceptableLanguages count] > 0) {
|
if (languagesOkaySoFar && [acceptableLanguages count] > 0) {
|
||||||
NSString* acceptLangHeader = [acceptableLanguages componentsJoinedByString:@","];
|
NSString* acceptLangHeader = [acceptableLanguages componentsJoinedByString:@","];
|
||||||
[self setPref:"intl.accept_languages" toString:acceptLangHeader];
|
[self setPref:"intl.accept_languages" toString:acceptLangHeader];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Fall back to the "en-us, en" default from all-camino.js - clear
|
||||||
|
// any existing user pref
|
||||||
|
[self clearPref:"intl.accept_languages"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the user-selected pref for the user agent locale if it exists
|
||||||
|
NSString* uaLocale = [self getStringPref:"camino.useragent.locale"
|
||||||
|
withSuccess:nil];
|
||||||
|
|
||||||
|
if (![uaLocale length]) {
|
||||||
|
// Find the active localization nib's name and make sure it's in
|
||||||
|
// ab or ab-CD form
|
||||||
|
NSArray* localizations = [[NSBundle mainBundle] preferredLocalizations];
|
||||||
|
if ([localizations count]) {
|
||||||
|
CFStringRef activeLocalization =
|
||||||
|
::CFLocaleCreateCanonicalLocaleIdentifierFromString(
|
||||||
|
NULL, (CFStringRef)[localizations objectAtIndex:0]);
|
||||||
|
if (activeLocalization) {
|
||||||
|
uaLocale = [PreferenceManager
|
||||||
|
convertLocaleToHTTPLanguage:(NSString*)activeLocalization];
|
||||||
|
::CFRelease(activeLocalization);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uaLocale && [uaLocale length]) {
|
||||||
|
[self setPref:"general.useragent.locale" toString:uaLocale];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSLog(@"Unable to determine user interface locale\n");
|
||||||
|
// Fall back to the "en-US" default from all.js. Clear any existing
|
||||||
|
// user pref.
|
||||||
|
[self clearPref:"general.useragent.locale"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// load up the default stylesheet (is this the best place to do this?)
|
// load up the default stylesheet (is this the best place to do this?)
|
||||||
|
@ -1099,6 +1133,12 @@ typedef enum EProxyConfig {
|
||||||
(void)mPrefs->SetBoolPref(prefName, (PRBool)value);
|
(void)mPrefs->SetBoolPref(prefName, (PRBool)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)clearPref:(const char*)prefName
|
||||||
|
{
|
||||||
|
if (mPrefs)
|
||||||
|
(void)mPrefs->ClearUserPref(prefName);
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString*)homePageUsingStartPage:(BOOL)checkStartupPagePref
|
- (NSString*)homePageUsingStartPage:(BOOL)checkStartupPagePref
|
||||||
{
|
{
|
||||||
if (!mPrefs)
|
if (!mPrefs)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче