[gnome-maps/wip/mlundblad/transit-service-discovery: 9/15] utils: Add function to get current language



commit a9f2a7f550e5e16f5e59361b2e14b9fc0d12ff56
Author: Marcus Lundblad <ml update uu se>
Date:   Sat Aug 31 12:52:43 2019 +0200

    utils: Add function to get current language
    
    Get current first-choice language, as ISO 639-2 code.

 src/utils.js | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/utils.js b/src/utils.js
index 2407e3c..f781e07 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -213,6 +213,15 @@ function getMeasurementSystem() {
     return measurementSystem;
 }
 
+/**
+ * Get the higest priority bare lange currently in use.
+ */
+function getLanguage() {
+    let locale = GLib.get_language_names()[0];
+    // the last item returned is the "bare" language
+    return GLib.get_locale_variants(locale).slice(-1)[0];
+}
+
 function getAccuracyDescription(accuracy) {
     switch(accuracy) {
     case Geocode.LOCATION_ACCURACY_UNKNOWN:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]