branch: externals/greader
commit 347141e4f9d0408ff95cacafde3ec058e2e6afd3
Author: Michelangelo Rodriguez <[email protected]>
Commit: Michelangelo Rodriguez <[email protected]>
fix(espeak): Extract 2-letter ISO code from get-language
The espeak set-voice completing-read can return identifiers like
"roa/it" or "en/en-gb". The get-language command must return a
2-letter ISO 639-1 code for greader-dict path construction.
Extract the code after the slash when present.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
greader-espeak.el | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/greader-espeak.el b/greader-espeak.el
index 8c23800d1c..3522594fe5 100644
--- a/greader-espeak.el
+++ b/greader-espeak.el
@@ -126,7 +126,16 @@ ARG is applied depending on the command."
('save-voice
(customize-save-variable 'greader-espeak-language arg))
('get-language
- greader-espeak-language)
+ (when greader-espeak-language
+ (let ((id greader-espeak-language))
+ ;; espeak identifiers: "it", "en", "roa/it", "en/en-gb".
+ ;; Extract the 2-letter code after the last slash, or from
+ ;; the start if no slash.
+ (when (string-match "/\\([a-z]\\{2\\}\\)" id)
+ (setq id (match-string 1 id)))
+ (if (string-match "\\`\\([a-z]\\{2\\}\\)" id)
+ (match-string 1 id)
+ id))))
('get-rate
greader-espeak-rate)
('audio-write