Bug 1409158 - Use LC_TIME to retrieve OSPreferences::GetRegionalPrefsLocales on Unix. r?jfkthame draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Mon, 16 Oct 2017 13:55:51 -0700
changeset 682820 183cf714b848f31ff5eec733ee0e113514ae1507
parent 680555 d71e8e0053d8043bc9deb98b35ca5220a0c9adea
child 683655 82c4a57099a59cebc6d8c394d9450d58441e55f5
push id85160
push userbmo:gandalf@aviary.pl
push dateWed, 18 Oct 2017 19:36:00 +0000
reviewersjfkthame
bugs1409158
milestone58.0a1
Bug 1409158 - Use LC_TIME to retrieve OSPreferences::GetRegionalPrefsLocales on Unix. r?jfkthame MozReview-Commit-ID: ImjQCggy8yk
intl/locale/gtk/OSPreferences_gtk.cpp
--- a/intl/locale/gtk/OSPreferences_gtk.cpp
+++ b/intl/locale/gtk/OSPreferences_gtk.cpp
@@ -23,19 +23,28 @@ OSPreferences::ReadSystemLocales(nsTArra
     return true;
   }
   return false;
 }
 
 bool
 OSPreferences::ReadRegionalPrefsLocales(nsTArray<nsCString>& aLocaleList)
 {
-  // For now we're just taking System Locales since we don't know of any better
-  // API for regional prefs.
-  return ReadSystemLocales(aLocaleList);
+  MOZ_ASSERT(aLocaleList.IsEmpty());
+
+  // For now we're just taking the LC_TIME from POSIX environment for all
+  // regional preferences.
+  nsAutoCString localeStr(setlocale(LC_TIME, nullptr));
+
+  if (CanonicalizeLanguageTag(localeStr)) {
+    aLocaleList.AppendElement(localeStr);
+    return true;
+  }
+
+  return false;
 }
 
 /*
  * This looks up into gtk settings for hourCycle format.
  *
  * This works for all GUIs that use gtk settings like Gnome, Elementary etc.
  * Ubuntu does not use those settings so we'll want to support them separately.
  *