Backed out changeset cc308a73ad05 (bug 1347314) for eslint failure in test_device.html. r=backout

This commit is contained in:
Sebastian Hengst 2017-03-22 18:20:26 +01:00
Родитель cb77ac3b2d
Коммит 0a04f3b9e2
37 изменённых файлов: 172 добавлений и 73 удалений

Просмотреть файл

@ -1002,9 +1002,12 @@ function formatDate(datestr, unknown) {
if (!date.valueOf())
return unknown;
const locale = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric",
hour: "numeric", minute: "numeric", second: "numeric" };
return date.toLocaleString(undefined, dtOptions);
return date.toLocaleString(locale, dtOptions);
}
function doCopy() {

Просмотреть файл

@ -544,8 +544,14 @@ XPCOMUtils.defineConstant(this, "PanelUI", PanelUI);
/**
* Gets the currently selected locale for display.
* @return the selected locale
* @return the selected locale or "en-US" if none is selected
*/
function getLocale() {
return Services.locale.getAppLocaleAsLangTag();
try {
let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry);
return chromeRegistry.getSelectedLocale("browser");
} catch (ex) {
return "en-US";
}
}

Просмотреть файл

@ -189,9 +189,12 @@ FeedWriter.prototype = {
__dateFormatter: null,
get _dateFormatter() {
if (!this.__dateFormatter) {
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric",
hour: "numeric", minute: "numeric" };
this.__dateFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
this.__dateFormatter = new Intl.DateTimeFormat(locale, dtOptions);
}
return this.__dateFormatter;
},

Просмотреть файл

@ -638,8 +638,10 @@ const AutoMigrate = {
// Strip out any empty elements, so an empty pref doesn't
// lead to a an array with 1 empty string in it.
surveyLocales = new Set(surveyLocales.filter(str => !!str));
let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry);
canDoSurveyInLocale =
surveyLocales.has(Services.locale.getAppLocaleAsLangTag());
surveyLocales.has(chromeRegistry.getSelectedLocale("global"));
} catch (ex) {
/* ignore exceptions and just don't do the survey. */
}

Просмотреть файл

@ -411,8 +411,11 @@ var PlacesOrganizer = {
populateRestoreMenu: function PO_populateRestoreMenu() {
let restorePopup = document.getElementById("fileRestorePopup");
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric" };
let dateFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
let dateFormatter = new Intl.DateTimeFormat(locale, dtOptions);
// Remove existing menu items. Last item is the restoreFromFile item.
while (restorePopup.childNodes.length > 1)

Просмотреть файл

@ -499,8 +499,11 @@ PlacesTreeView.prototype = {
__todayFormatter: null,
get _todayFormatter() {
if (!this.__todayFormatter) {
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { hour: "numeric", minute: "numeric" };
this.__todayFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
this.__todayFormatter = new Intl.DateTimeFormat(locale, dtOptions);
}
return this.__todayFormatter;
},
@ -508,9 +511,12 @@ PlacesTreeView.prototype = {
__dateFormatter: null,
get _dateFormatter() {
if (!this.__dateFormatter) {
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "numeric", day: "numeric",
hour: "numeric", minute: "numeric" };
this.__dateFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
this.__dateFormatter = new Intl.DateTimeFormat(locale, dtOptions);
}
return this.__dateFormatter;
},

Просмотреть файл

@ -104,6 +104,9 @@
ok(rc >= 3, "Rows found");
let columns = tree.columns;
ok(columns.count > 0, "Columns found");
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
for (let r = 0; r < rc; r++) {
let node = treeView.nodeForTreeIndex(r);
ok(node, "Places node found");
@ -135,7 +138,7 @@
// a redirecting uri could be put in the tree while we test.
break;
}
let timeStr = timeObj.toLocaleString(undefined, dtOptions);
let timeStr = timeObj.toLocaleString(locale, dtOptions);
is(text, timeStr, "Date format is correct");
break;

Просмотреть файл

@ -497,9 +497,12 @@ var gCookiesWindow = {
formatExpiresString(aExpires) {
if (aExpires) {
var date = new Date(1000 * aExpires);
const locale = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric",
hour: "numeric", minute: "numeric", second: "numeric" };
return date.toLocaleString(undefined, dtOptions);
return date.toLocaleString(locale, dtOptions);
}
return this._bundle.getString("expireAtEndOfSession");
},

Просмотреть файл

@ -85,9 +85,12 @@ function resetPreferences() {
function formatInstallDate(sec) {
var date = new Date(sec);
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric",
hour: "numeric", minute: "numeric", second: "numeric" };
return date.toLocaleString(undefined, dtOptions);
return date.toLocaleString(locale, dtOptions);
}
registerCleanupFunction(resetPreferences);

Просмотреть файл

@ -33,7 +33,9 @@ this.Translation = {
_defaultTargetLanguage: "",
get defaultTargetLanguage() {
if (!this._defaultTargetLanguage) {
this._defaultTargetLanguage = Services.locale.getAppLocaleAsLangTag()
this._defaultTargetLanguage = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global")
.split("-")[0];
}
return this._defaultTargetLanguage;

Просмотреть файл

@ -264,7 +264,9 @@
"C\u1EA3m \u01A1n"]
};
let locale = Services.locale.getAppLocaleAsLangTag();
let locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("browser");
if (!(locale in localizedStrings))
locale = "en";
let strings = localizedStrings[locale];

Просмотреть файл

@ -269,7 +269,8 @@ Experiments.Policy.prototype = {
},
locale() {
return Services.locale.getAppLocaleAsLangTag();
let chrome = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
return chrome.getSelectedLocale("global");
},
/**

Просмотреть файл

@ -194,9 +194,7 @@ locale
A locale identifier is a string like ``en-US`` or ``zh-CN`` and is
obtained by looking at
``LocaleService.getAppLocaleAsLangTag()``.
For infamous `ja-JP-mac` case, this will return it in
the language tag form (`ja-JP-mac`).
``nsIXULChromeRegistry.getSelectedLocale("global")``.
The client should compare its locale identifier to members of this array.
If a match is found, the experiment is applicable.

Просмотреть файл

@ -570,7 +570,10 @@ var pktUI = (function() {
}
function getUILocale() {
return Services.locale.getAppLocaleAsLangTag();
var locale = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry).
getSelectedLocale("browser");
return locale;
}
/**

Просмотреть файл

@ -250,7 +250,9 @@ var pktApi = (function() {
var url = baseAPIUrl + options.path;
var data = options.data || {};
data.locale_lang = Services.locale.getAppLocaleAsLangTag();
data.locale_lang = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry).
getSelectedLocale("browser");
data.consumer_key = oAuthConsumerKey;
var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Components.interfaces.nsIXMLHttpRequest);

Просмотреть файл

@ -34,7 +34,9 @@ this.NormandyDriver = function(sandboxManager, extraContext = {}) {
testing: false,
get locale() {
return Services.locale.getAppLocaleAsLangTag();
return Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("browser");
},
get userId() {

Просмотреть файл

@ -4,6 +4,7 @@
"use strict";
const { Ci, Cc } = require("chrome");
const Services = require("Services");
const { DOMHelpers } = require("resource://devtools/client/shared/DOMHelpers.jsm");
const { Task } = require("devtools/shared/task");
@ -15,6 +16,9 @@ const DEV_EDITION_PROMO_URL = "chrome://devtools/content/framework/dev-edition-p
const DEV_EDITION_PROMO_ENABLED_PREF = "devtools.devedition.promo.enabled";
const DEV_EDITION_PROMO_SHOWN_PREF = "devtools.devedition.promo.shown";
const DEV_EDITION_PROMO_URL_PREF = "devtools.devedition.promo.url";
const LOCALE = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global");
/**
* Only show Dev Edition promo if it's enabled (beta channel),
@ -24,7 +28,7 @@ const DEV_EDITION_PROMO_URL_PREF = "devtools.devedition.promo.url";
function shouldDevEditionPromoShow() {
return Services.prefs.getBoolPref(DEV_EDITION_PROMO_ENABLED_PREF) &&
!Services.prefs.getBoolPref(DEV_EDITION_PROMO_SHOWN_PREF) &&
Services.locale.getAppLocaleAsLangTag() === "en-US";
LOCALE === "en-US";
}
var TYPES = {

Просмотреть файл

@ -54,7 +54,8 @@ window.onload = function () {
geckobuildid: appInfo.platformBuildID,
geckoversion: appInfo.platformVersion,
useragent: window.navigator.userAgent,
locale: Services.locale.getAppLocaleAsLangTag(),
locale: Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"),
os: appInfo.OS,
processor: appInfo.XPCOMABI.split("-")[0],
compiler: appInfo.XPCOMABI.split("-")[1],

Просмотреть файл

@ -132,7 +132,8 @@ function* getSystemInfo() {
geckoversion: geckoVersion,
// Locale used in this build
locale: Services.locale.getAppLocaleAsLangTag(),
locale: Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"),
/**
* Information regarding the operating system.

Просмотреть файл

@ -8,11 +8,9 @@
#include "mozilla/dom/EncodingUtils.h"
#include "nsUConvPropertySearch.h"
#include "nsIChromeRegistry.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/intl/LocaleService.h"
using mozilla::intl::LocaleService;
namespace mozilla {
namespace dom {
@ -68,7 +66,11 @@ FallbackEncoding::Get(nsACString& aFallback)
}
nsAutoCString locale;
LocaleService::GetInstance()->GetAppLocaleAsLangTag(locale);
nsCOMPtr<nsIXULChromeRegistry> registry =
mozilla::services::GetXULChromeRegistryService();
if (registry) {
registry->GetSelectedLocale(NS_LITERAL_CSTRING("global"), false, locale);
}
// Let's lower case the string just in case unofficial language packs
// don't stick to conventions.

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsIServiceManager.h"
#include "nsIURI.h"
#include "nsIChromeRegistry.h"
#include "nsIFile.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
@ -27,11 +28,9 @@
#include "mozilla/scache/StartupCache.h"
#include "mozilla/scache/StartupCacheUtils.h"
#include "mozilla/Telemetry.h"
#include "mozilla/intl/LocaleService.h"
using namespace mozilla;
using namespace mozilla::scache;
using mozilla::intl::LocaleService;
static bool gDisableXULCache = false; // enabled by default
static const char kDisableXULCachePref[] = "nglayout.debug.disable_xul_cache";
@ -500,8 +499,12 @@ nsXULPrototypeCache::BeginCaching(nsIURI* aURI)
rv = aURI->GetHost(package);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIXULChromeRegistry> chromeReg
= do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
nsAutoCString locale;
LocaleService::GetInstance()->GetAppLocaleAsLangTag(locale);
rv = chromeReg->GetSelectedLocale(package, false, locale);
if (NS_FAILED(rv))
return rv;
nsAutoCString fileChromePath, fileLocale;

Просмотреть файл

@ -8,9 +8,9 @@
#include "mozilla/Attributes.h" // for final
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/Services.h" // for GetXULChromeRegistryService
#include "mozilla/dom/Element.h" // for Element
#include "mozilla/dom/Selection.h"
#include "mozilla/intl/LocaleService.h" // for retrieving app locale
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsAString.h" // for nsAString::IsEmpty, etc
#include "nsComponentManagerUtils.h" // for do_CreateInstance
@ -18,6 +18,7 @@
#include "nsDependentSubstring.h" // for Substring
#include "nsEditorSpellCheck.h"
#include "nsError.h" // for NS_ERROR_NOT_INITIALIZED, etc
#include "nsIChromeRegistry.h" // for nsIXULChromeRegistry
#include "nsIContent.h" // for nsIContent
#include "nsIContentPrefService.h" // for nsIContentPrefService, etc
#include "nsIContentPrefService2.h" // for nsIContentPrefService2, etc
@ -48,7 +49,6 @@
using namespace mozilla;
using namespace mozilla::dom;
using mozilla::intl::LocaleService;
class UpdateDictionaryHolder {
private:
@ -916,16 +916,21 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
// Priority 4:
// As next fallback, try the current locale.
if (NS_FAILED(rv)) {
nsAutoCString utf8DictName;
LocaleService::GetInstance()->GetAppLocaleAsLangTag(utf8DictName);
nsCOMPtr<nsIXULChromeRegistry> packageRegistry =
mozilla::services::GetXULChromeRegistryService();
dictName.Assign(EmptyString());
AppendUTF8toUTF16(utf8DictName, dictName);
if (packageRegistry) {
nsAutoCString utf8DictName;
rv2 = packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"),
false, utf8DictName);
dictName.Assign(EmptyString());
AppendUTF8toUTF16(utf8DictName, dictName);
#ifdef DEBUG_DICT
printf("***** Trying locale |%s|\n",
NS_ConvertUTF16toUTF8(dictName).get());
printf("***** Trying locale |%s|\n",
NS_ConvertUTF16toUTF8(dictName).get());
#endif
rv = TryDictionary (dictName, dictList, DICT_COMPARE_CASE_INSENSITIVE);
rv = TryDictionary (dictName, dictList, DICT_COMPARE_CASE_INSENSITIVE);
}
}
if (NS_FAILED(rv)) {

Просмотреть файл

@ -7,15 +7,14 @@
#include "ICUUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/intl/LocaleService.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIToolkitChromeRegistry.h"
#include "nsStringGlue.h"
#include "unicode/uloc.h"
#include "unicode/unum.h"
using namespace mozilla;
using mozilla::intl::LocaleService;
/**
* This pref just controls whether we format the number with grouping separator
@ -71,11 +70,17 @@ ICUUtils::LanguageTagIterForContent::GetNext(nsACString& aBCP47LangTag)
if (mCurrentFallbackIndex < 2) {
mCurrentFallbackIndex = 2;
// Else take the app's locale:
nsAutoCString appLocale;
LocaleService::GetInstance()->GetAppLocaleAsBCP47(aBCP47LangTag);
return;
// Else try the user-agent's locale:
nsCOMPtr<nsIToolkitChromeRegistry> cr =
mozilla::services::GetToolkitChromeRegistryService();
nsAutoCString uaLangTag;
if (cr) {
cr->GetSelectedLocale(NS_LITERAL_CSTRING("global"), true, uaLangTag);
}
if (!uaLangTag.IsEmpty()) {
aBCP47LangTag = uaLangTag;
return;
}
}
// TODO: Probably not worth it, but maybe have a fourth fallback to using

Просмотреть файл

@ -112,7 +112,9 @@ function getAddons() {
* @return {String} JSON data of application details
*/
function getApplicationDetails() {
var locale = Services.locale.getAppLocaleAsLangTag();
var locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global");
// Put all our necessary information into JSON and return it:
// appinfo, startupinfo, and addons

Просмотреть файл

@ -30,9 +30,9 @@ class AppInfo(BaseLib):
def locale(self):
with self.marionette.using_context('chrome'):
return self.marionette.execute_script("""
return Components.classes["@mozilla.org/intl/localeservice;1"]
.getService(Components.interfaces.mozILocaleService)
.getAppLocaleAsLangTag();
return Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global");
""")
@property

Просмотреть файл

@ -88,7 +88,9 @@ nsURLFormatterService.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIURLFormatter]),
_defaults: {
LOCALE: () => Services.locale.getAppLocaleAsLangTag(),
LOCALE: () => Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry).
getSelectedLocale('global'),
REGION: function() {
try {
// When the geoip lookup failed to identify the region, we fallback to

Просмотреть файл

@ -4,9 +4,9 @@
function run_test() {
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Ci.nsIURLFormatter);
var locale = Cc["@mozilla.org/intl/localeservice;1"].
getService(Ci.mozILocaleService).
getAppLocaleAsLangTag();
var locale = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry).
getSelectedLocale("global");
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var sysInfo = Cc["@mozilla.org/system-info;1"].

Просмотреть файл

@ -98,7 +98,7 @@
<method name="initPicker">
<parameter name="detail"/>
<body><![CDATA[
const locale = Services.locale.getAppLocaleAsBCP47();
const locale = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global");
const dir = this.mozIntl.getLocaleInfo(locale).direction;
switch (this.type) {

Просмотреть файл

@ -80,11 +80,14 @@ function populateReportList() {
var dateFormatter;
var timeFormatter;
try {
dateFormatter = new Intl.DateTimeFormat(undefined, { year: "2-digit",
month: "numeric",
day: "numeric" });
timeFormatter = new Intl.DateTimeFormat(undefined, { hour: "numeric",
minute: "numeric" });
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
dateFormatter = new Intl.DateTimeFormat(locale, { year: "2-digit",
month: "numeric",
day: "numeric" });
timeFormatter = new Intl.DateTimeFormat(locale, { hour: "numeric",
minute: "numeric" });
} catch (e) {
// XXX Fallback to be removed once bug 1215247 is complete
// and the Intl API is available on all platforms.

Просмотреть файл

@ -348,6 +348,14 @@ this.DownloadUtils = {
// Figure out when today begins
let today = new Date(aNow.getFullYear(), aNow.getMonth(), aNow.getDate());
// Get locale to use for date/time formatting
// TODO: Remove Intl fallback when no longer needed (bug 1344543).
const locale = typeof Intl === "undefined"
? undefined
: Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
// Figure out if the time is from today, yesterday, this week, etc.
let dateTimeCompact;
if (aDate >= today) {
@ -364,12 +372,12 @@ this.DownloadUtils = {
// After last week started, show day of week
dateTimeCompact = typeof Intl === "undefined"
? aDate.toLocaleFormat("%A")
: aDate.toLocaleDateString(undefined, { weekday: "long" });
: aDate.toLocaleDateString(locale, { weekday: "long" });
} else {
// Show month/day
let month = typeof Intl === "undefined"
? aDate.toLocaleFormat("%B")
: aDate.toLocaleDateString(undefined, { month: "long" });
: aDate.toLocaleDateString(locale, { month: "long" });
let date = aDate.getDate();
dateTimeCompact = gBundle.formatStringFromName(gStr.monthDate, [month, date], 2);
}

Просмотреть файл

@ -78,6 +78,13 @@ function testAllGetReadableDates() {
const sixdaysago = new Date(2000, 11, 25, 11, 30, 15);
const sevendaysago = new Date(2000, 11, 24, 11, 30, 15);
// TODO: Remove Intl fallback when no longer needed (bug 1344543).
const locale = typeof Intl === "undefined"
? undefined
: Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
let dts = Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
getService(Components.interfaces.nsIScriptableDateFormat);
@ -90,15 +97,15 @@ function testAllGetReadableDates() {
testGetReadableDates(twodaysago,
typeof Intl === "undefined"
? twodaysago.toLocaleFormat("%A")
: twodaysago.toLocaleDateString(undefined, { weekday: "long" }));
: twodaysago.toLocaleDateString(locale, { weekday: "long" }));
testGetReadableDates(sixdaysago,
typeof Intl === "undefined"
? sixdaysago.toLocaleFormat("%A")
: sixdaysago.toLocaleDateString(undefined, { weekday: "long" }));
: sixdaysago.toLocaleDateString(locale, { weekday: "long" }));
testGetReadableDates(sevendaysago,
(typeof Intl === "undefined"
? sevendaysago.toLocaleFormat("%B")
: sevendaysago.toLocaleDateString(undefined, { month: "long" })) + " " +
: sevendaysago.toLocaleDateString(locale, { month: "long" })) + " " +
sevendaysago.getDate().toString().padStart(2, "0"));
let [, dateTimeFull] = DownloadUtils.getReadableDates(today_11_30);

Просмотреть файл

@ -1626,8 +1626,11 @@ function openOptionsInTab(optionsURL) {
}
function formatDate(aDate) {
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric" };
return aDate.toLocaleDateString(undefined, dtOptions);
return aDate.toLocaleDateString(locale, dtOptions);
}

Просмотреть файл

@ -1191,8 +1191,11 @@
<method name="_updateDates">
<body><![CDATA[
function formatDate(aDate) {
const locale = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric" };
return aDate.toLocaleDateString(undefined, dtOptions);
return aDate.toLocaleDateString(locale, dtOptions);
}
if (this.mAddon.updateDate)

Просмотреть файл

@ -96,7 +96,8 @@ add_task(function* initializeState() {
}
});
gIsEnUsLocale = Services.locale.getAppLocaleAsLangTag() == "en-US";
let chrome = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
gIsEnUsLocale = chrome.getSelectedLocale("global") == "en-US";
// The Experiments Manager will interfere with us by preventing installs
// of experiments it doesn't know about. We remove it from the equation

Просмотреть файл

@ -499,8 +499,11 @@ function get_string(aName, ...aArgs) {
}
function formatDate(aDate) {
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric" };
return aDate.toLocaleDateString(undefined, dtOptions);
return aDate.toLocaleDateString(locale, dtOptions);
}
function is_hidden(aElement) {

Просмотреть файл

@ -59,9 +59,12 @@ var gUpdateHistory = {
*/
_formatDate(seconds) {
var date = new Date(seconds);
const locale = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry)
.getSelectedLocale("global", true);
const dtOptions = { year: "numeric", month: "long", day: "numeric",
hour: "numeric", minute: "numeric", second: "numeric" };
return date.toLocaleString(undefined, dtOptions);
return date.toLocaleString(locale, dtOptions);
}
};

Просмотреть файл

@ -150,9 +150,10 @@ HandlerService.prototype = {
},
get _currentLocale() {
const locSvc = Cc["@mozilla.org/intl/localeservice;1"].
getService(Ci.mozILocaleService);
return locSvc.getAppLocaleAsLangTag();
var chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry);
var currentLocale = chromeRegistry.getSelectedLocale("global");
return currentLocale;
},
_destroy: function HS__destroy() {