summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dom/base/nsGlobalWindow.cpp12
-rw-r--r--dom/base/nsGlobalWindow.h3
-rw-r--r--dom/webidl/Window.webidl15
3 files changed, 30 insertions, 0 deletions
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index c6b35a9bf0..be1c2463e5 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -49,6 +49,7 @@
#include "nsNetUtil.h"
#include "nsVariant.h"
#include "nsPrintfCString.h"
+#include "mozilla/intl/LocaleService.h"
// Helper Classes
#include "nsJSUtils.h"
@@ -14794,6 +14795,17 @@ nsGlobalWindow::CreateWorklet(ErrorResult& aRv)
return worklet.forget();
}
+void
+nsGlobalWindow::GetAppLocales(nsTArray<nsString>& aLocales)
+{
+ nsTArray<nsCString> appLocales;
+ mozilla::intl::LocaleService::GetInstance()->GetAppLocales(appLocales);
+
+ for (uint32_t i = 0; i < appLocales.Length(); i++) {
+ aLocales.AppendElement(NS_ConvertUTF8toUTF16(appLocales[i]));
+ }
+}
+
template class nsPIDOMWindow<mozIDOMWindowProxy>;
template class nsPIDOMWindow<mozIDOMWindow>;
template class nsPIDOMWindow<nsISupports>;
diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h
index e42835a0b2..43270e80d9 100644
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -897,6 +897,9 @@ public:
already_AddRefed<mozilla::dom::Worklet>
CreateWorklet(mozilla::ErrorResult& aRv);
+ void
+ GetAppLocales(nsTArray<nsString>& aLocales);
+
protected:
bool AlertOrConfirm(bool aAlert, const nsAString& aMessage,
nsIPrincipal& aSubjectPrincipal,
diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl
index 1b98042473..8a6b05a88e 100644
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -486,3 +486,18 @@ callback IdleRequestCallback = void (IdleDeadline deadline);
partial interface Window {
[ChromeOnly] readonly attribute boolean isSecureContextIfOpenerIgnored;
};
+
+partial interface Window {
+/**
+ * Returns a list of locales that the application should be localized to.
+ *
+ * The result is a sorted list of valid locale IDs and it should be
+ * used for all APIs that accept list of locales, like ECMA402 and L10n APIs.
+ *
+ * This API always returns at least one locale.
+ *
+ * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
+ */
+ [Func="IsChromeOrXBL"]
+ sequence<DOMString> getAppLocales();
+}; \ No newline at end of file