From ec2d230d1bbf1adff0b35069904d2afd39ec3aa3 Mon Sep 17 00:00:00 2001 From: Ribas160 Date: Fri, 29 May 2026 15:43:41 +0300 Subject: [PATCH] refactor: deduplicate OS-specific hotkey detection into a shared helper --- lib/I18n.php | 13 +++++++++++++ tpl/bootstrap.php | 3 +-- tpl/bootstrap5.php | 3 +-- tpl/shortenerproxy.php | 3 +-- tst/I18nTest.php | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/I18n.php b/lib/I18n.php index 287e2a00..14c109bf 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -297,6 +297,19 @@ class I18n return in_array(self::$_language, array('ar', 'he')); } + /** + * get OS-specific copy hotkey modifier key name based on user agent + * + * @access public + * @static + * @return string 'Cmd' on macOS, 'Ctrl' otherwise + */ + public static function getCopyHotkey() + { + return isset($_SERVER['HTTP_USER_AGENT']) && + strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ? 'Cmd' : 'Ctrl'; + } + /** * set the default language * diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 9a542234..4a60b534 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -626,8 +626,7 @@ endif;
diff --git a/tpl/bootstrap5.php b/tpl/bootstrap5.php index 6ea9c209..a1ac5600 100644 --- a/tpl/bootstrap5.php +++ b/tpl/bootstrap5.php @@ -483,8 +483,7 @@ endif;