[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/greader 3933e92342 2/4: greader.el: added function "gre
From: |
ELPA Syncer |
Subject: |
[elpa] externals/greader 3933e92342 2/4: greader.el: added function "greader--get-local-language" |
Date: |
Fri, 17 Nov 2023 03:58:04 -0500 (EST) |
branch: externals/greader
commit 3933e92342818bf247a7bfc7f3fa2447f9d3ffe3
Author: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
Commit: Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com>
greader.el: added function "greader--get-local-language"
This is an utility feature that helps make more robust
"greader-get-language" function.
The idea for this function comes from the observation that the back-ends
can also be written by others and not implement the command
"get-language".
---
greader.el | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/greader.el b/greader.el
index 4ea0a01f60..e2fe571e1c 100644
--- a/greader.el
+++ b/greader.el
@@ -675,6 +675,16 @@ buffer, so if you want to set it globally, please use
"Set punctuation to FLAG."
(greader-call-backend 'punctuation flag))
+(defun greader--get-local-language ()
+ "Returns the language code from the system's locale."
+ (let ((locale (or (getenv "LANG") ; First try with the LANG environment
variable
+ (getenv "LC_ALL") ; Then with LC_ALL
+ "en"))) ; Default to "en" if nothing is found
+ ;; Extracts the language code from the locale (e.g., "en_US.UTF-8" becomes
"en")
+ (if (string-match "\\([a-z]+\\)_" locale)
+ (match-string 1 locale)
+ "en"))) ; Default to "en" if the locale format is unrecognized
+
(defun greader-get-language ()
"return language set in current back-end."
(greader-call-backend 'get-language))