From e37f2a0a30f6cb2504123488c127092227782083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Wed, 1 Jun 2022 16:27:22 +0200 Subject: [PATCH] Use U+003A colon character on RTL languages Unfortunately U+2236 seems to break time labels on RTL languages. Check text direction at startup and select best one that works. --- src/buttons.js | 2 +- src/controls.js | 2 +- src/main.js | 5 +++++ src/misc.js | 5 +++-- src/revealers.js | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/buttons.js b/src/buttons.js index e09b2598..f6c5d30c 100644 --- a/src/buttons.js +++ b/src/buttons.js @@ -165,7 +165,7 @@ class ClapperElapsedTimeButton extends PopoverButtonBase setInitialState() { - this.label = '00∶00∕00∶00'; + this.label = `00${Misc.timeColon}00∕00${Misc.timeColon}00`; } setFullscreenMode(isFullscreen, isMobileMonitor) diff --git a/src/controls.js b/src/controls.js index b74b2f1c..ce82e591 100644 --- a/src/controls.js +++ b/src/controls.js @@ -27,7 +27,7 @@ class ClapperControls extends Gtk.Box this.isMobile = false; this.showHours = false; - this.durationFormatted = '00∶00'; + this.durationFormatted = `00${Misc.timeColon}00`; this.revealersArr = []; this.chapters = null; diff --git a/src/main.js b/src/main.js index 29c7e4e0..d6f3ebfd 100644 --- a/src/main.js +++ b/src/main.js @@ -10,6 +10,7 @@ Debug.debug('imports'); const { GstClapper, Gtk, Adw } = imports.gi; const { App } = imports.src.app; +const Misc = imports.src.misc; function main(argv) { @@ -19,6 +20,10 @@ function main(argv) Gtk.init(); Adw.init(); + /* U+2236 seems to break RTL languages, use U+003A instead */ + if(Gtk.Widget.get_default_direction() === Gtk.TextDirection.RTL) + Misc.timeColon = ':'; + Debug.debug('initialized'); new App().run(argv); diff --git a/src/misc.js b/src/misc.js index b10ccb27..f9a612b2 100644 --- a/src/misc.js +++ b/src/misc.js @@ -9,6 +9,7 @@ var subsMimes = [ 'application/x-subrip', 'text/x-ssa', ]; +var timeColon = '∶'; var settings = new Gio.Settings({ schema_id: appId, @@ -161,8 +162,8 @@ function getFormattedTime(time, showHours) time -= minutes * 60; const seconds = ('0' + Math.floor(time)).slice(-2); - const parsed = (hours) ? `${hours}∶` : ''; - return parsed + `${minutes}∶${seconds}`; + const parsed = (hours) ? `${hours}${timeColon}` : ''; + return parsed + `${minutes}${timeColon}${seconds}`; } function parsePlaylistFiles(filesArray) diff --git a/src/revealers.js b/src/revealers.js index 1ddc08a6..7aac9f64 100644 --- a/src/revealers.js +++ b/src/revealers.js @@ -59,8 +59,8 @@ class ClapperRevealerTop extends CustomRevealer const initTime = GLib.DateTime.new_now_local().format('%X'); this.timeFormat = (initTime.length > 8) - ? '%I∶%M %p' - : '%H∶%M'; + ? `%I${Misc.timeColon}%M %p` + : `%H${Misc.timeColon}%M`; this.mediaTitle = new Gtk.Label({ ellipsize: Pango.EllipsizeMode.END,