[gnome-maps] storedRoute: Print route summary according to locale direction



commit 32cc59db33baac07177c2bc50aab1dfa08967149
Author: Marcus Lundblad <ml update uu se>
Date:   Mon May 15 23:03:43 2017 +0200

    storedRoute: Print route summary according to locale direction
    
    Reverse the direction of separating arrows of stored route search results.
    Also add Unicode directional characters according to the locale direction
    to get the right rendering order for place names using the "opposite"
    direction from the currently running locale.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782608

 src/storedRoute.js |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/storedRoute.js b/src/storedRoute.js
index 0912635..ca3b870 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -22,12 +22,17 @@
 
 const Champlain = imports.gi.Champlain;
 const Gio = imports.gi.Gio;
+const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
 
 const Place = imports.place;
 const Route = imports.route;
 const RouteQuery = imports.routeQuery;
 
+// directional override markers
+const _RLM = '\u200F';
+const _LRM = '\u200E';
+
 var StoredRoute = new Lang.Class({
     Name: 'StoredRoute',
     Extends: Place.Place,
@@ -46,9 +51,15 @@ var StoredRoute = new Lang.Class({
                             time: route.time,
                             bbox: route.bbox });
 
+        this._rtl = Gtk.get_locale_direction() === Gtk.TextDirection.RTL;
+
         let places = params.places;
         delete params.places;
-        params.name = places[0].name + ' → ' + places[places.length -1].name;
+        let directionMarker = this._rtl ? _RLM : _LRM;
+        let arrow = this._rtl ? '←' : '→';
+        params.name = directionMarker + places[0].name + directionMarker +
+                      arrow + directionMarker + places[places.length -1].name;
+
 
         let geoclue = params.geoclue;
         delete params.geoclue;
@@ -71,9 +82,11 @@ var StoredRoute = new Lang.Class({
     },
 
     get viaString() {
+        let directionMarker = this._rtl ? _RLM : _LRM;
+        let arrow = this._rtl ? '←' : '→';
         return this.places.map(function(place) {
-            return place.name;
-        }).join(' → ');
+            return directionMarker + place.name;
+        }).join(directionMarker + arrow);
     },
 
     get transportation() {


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