[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erbot-cvs] erbot erbtranslate.el ChangeLog
From: |
Vivek Dasmohapatra |
Subject: |
[Erbot-cvs] erbot erbtranslate.el ChangeLog |
Date: |
Tue, 09 May 2006 18:00:06 +0000 |
CVSROOT: /sources/erbot
Module name: erbot
Branch:
Changes by: Vivek Dasmohapatra <address@hidden> 06/05/09 18:00:06
Modified files:
. : erbtranslate.el ChangeLog
Log message:
Implement list of languages emacs can't support yet.
Provide full-name helper function for language codes and use it.
More helpful messages + more data from list-languages function.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/erbot/erbot/erbtranslate.el.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/erbot/erbot/ChangeLog.diff?tr1=1.53&tr2=1.54&r1=text&r2=text
Patches:
Index: erbot/ChangeLog
diff -u erbot/ChangeLog:1.53 erbot/ChangeLog:1.54
--- erbot/ChangeLog:1.53 Mon May 8 16:47:37 2006
+++ erbot/ChangeLog Tue May 9 18:00:06 2006
@@ -1,3 +1,17 @@
+2006-05-09 Vivek Dasmohapatra <address@hidden>
+
+ * erbtranslate.el (fsi-translate-list-pairs): improved help, return
+ more information when < N pairs, where N is currently 20. (Always
+ return full list if both origin and destination are both supplied)
+ (erbtranslate-full-name): returns a "full name" for a language,
+ consisting of all its human-readable aliases.
+ (erbtranslate-unsupported-langs): list of languages emacs can't utf-8
+ encode yet.
+ (fsi-translate): abort for non-unicodable languages like Arabic and
+ Hebrew.
+ (fsi-translate): Use full names of languages in error messages.
+ (fsi-translate-list-pairs): Use full names of languages in messages.
+
2006-05-08 Vivek Dasmohapatra <address@hidden>
* erbtranslate.el (erbtranslate-parse-pair): parse the output of
Index: erbot/erbtranslate.el
diff -u erbot/erbtranslate.el:1.11 erbot/erbtranslate.el:1.12
--- erbot/erbtranslate.el:1.11 Mon May 8 16:47:37 2006
+++ erbot/erbtranslate.el Tue May 9 18:00:05 2006
@@ -47,6 +47,9 @@
usually text, and occasionally web-page as well. No other types are currently
known.")
+(defvar erbtranslate-unsupported-langs '("ar" "he")
+ "Languages (two letter codes) that we cannot utf-8 encode yet.")
+
(defun erbtranslate-enabled-check ()
(erbutils-enabled-check erbn-translate-p))
@@ -69,6 +72,20 @@
erbtranslate-pairs)
code))
+(defun erbtranslate-full-name (code-or-name)
+ "Return the full name of a language based on a code or one of its aliases."
+ (let ((name nil) (lang nil) (ldata erbtranslate-pairs))
+ (while (and ldata (not name))
+ (setq lang (car ldata) ldata (cdr ldata))
+ (if (member-ignore-case code-or-name (car lang))
+ (setq lang (car lang))
+ (if (member-ignore-case code-or-name (cadr lang))
+ (setq lang (cadr lang))
+ (setq lang nil)))
+ (when lang
+ (setq name (mapconcat (lambda (l) (format "%s" l)) (cdr lang) " ")) ))
+ name))
+
(defun fsi-translate (from to &rest text)
(erbtranslate-enabled-check)
(require 'shs)
@@ -92,16 +109,23 @@
;;(locale (getenv "LC_ALL"))
)
(setq code (erbtranslate-req-to-pair from-lang to-lang))
- (if (not code)
- (format "%s -> %s: no matching translation services found."
- from-lang to-lang)
- ;;(message "=> string is %S" (string-to-sequence text 'vector))
- (setq translation
- (shsp (list erbn-translate-program
- "-f" (car code) "-t" (cdr code)) nil text))
- (setq translation (decode-coding-string translation 'utf-8))
- ;;(message "<= string is %S" (string-to-sequence translation 'vector))
- translation)))
+ (cond
+ ( (not code)
+ (concat (format "%s -> %s: no matching translation services found.\n"
+ from-lang to-lang)
+ "Syntax: translate FROM TO TEXT\n") )
+ ( (member (car code) erbtranslate-unsupported-langs)
+ (format "Sorry, unicode support for %s is not yet complete."
+ (erbtranslate-full-name from)) )
+ ( (member (cdr code) erbtranslate-unsupported-langs)
+ (format "Sorry, unicode support for %s is not yet complete."
+ (erbtranslate-full-name to)) )
+ (t
+ (setq translation
+ (shsp (list erbn-translate-program
+ "-f" (car code) "-t" (cdr code)) nil text)
+ translation (decode-coding-string translation 'utf-8))
+ translation)) ))
(defalias 'fsi-t8-l 'fsi-translate-list-pairs)
@@ -167,28 +191,39 @@
"Allow the user to search for translation pairs. Only gives counts
unless both from and to are specified. *, any, - are allowed as wildcards."
(erbtranslate-enabled-check)
- (setq from (format "%s" from)
- to (format "%s" to ))
+ (setq from (format "%s" (or from "*"))
+ to (format "%s" (or to "*")))
(if (string-match "^\\(?:\*\\|any\\|-\\|\\)$" from) (setq from nil))
(if (string-match "^\\(?:\*\\|any\\|-\\|\\)$" to ) (setq to nil))
(if (not (erbtranslate-load-pairs))
"translate doesn't seem to have been setup - no languages found."
(cond
- ( (and (not from) (not to))
- (format "%d language pair(s) available." (length erbtranslate-pairs)) )
- ( (not to)
- (let ( (x 0) (fl (format "%s" from)) )
- (mapc
- (lambda (p) (if (member-ignore-case fl (car p)) (setq x (1+ x))))
- erbtranslate-pairs)
- (format "From %s: %d pair(s) available." fl x)) )
- ( (not from)
- (let ( (x 0) (tl (format "%s" to)) )
+ ( (and (not from) (not to)) ;; neither end point specified
+ (concat
+ (format "%d language pair(s) available." (length erbtranslate-pairs))
+ "Specify an origin and/or destination language to see a list:\n"
+ " translate-list-pairs es ja\n"
+ " translate-list-pairs castilian\n"
+ " translate-list-pairs * zh-TW\n") )
+ ( (or (not to) (not from)) ;; one end point specified
+ (let ( (dir (if from "From" "To"))
+ (op (if from 'car 'cadr))
+ (s nil)
+ (x 0)
+ (fl (format "%s" (or from to))) )
(mapc
- (lambda (p) (if (member-ignore-case tl (cadr p)) (setq x (1+ x))))
+ (lambda (p) (if (member-ignore-case fl (funcall op p))
+ (setq x (1+ x) s (cons p s))))
erbtranslate-pairs)
- (format "To %s: %d pair(s) available.\n" tl x)) )
- (t
+ (if (< 0 x) (setq fl (or (erbtranslate-full-name fl) fl)))
+ (apply 'concat
+ (format "%s %s: %d language(s) available.\n" dir fl x)
+ (if (<= (length s) 20)
+ (mapcar (lambda (x)
+ (format "%s -> %s\n"
+ (princ (car x))
+ (princ (cadr x)))) s)) )) )
+ (t ;; fully spec'd translation
(let ( (s nil)
(x 0)
(fl (format "%s" from))
@@ -198,6 +233,9 @@
(if (and (member-ignore-case fl (car p)) (member tl (cadr p)))
(setq x (1+ x) s (cons p s)) ))
erbtranslate-pairs)
+ (if (< 0 x)
+ (setq fl (or (erbtranslate-full-name fl) fl)
+ tl (or (erbtranslate-full-name tl) tl)))
(apply 'concat
(format "%s -> %s: %d pair(s) available.\n" fl tl x)
(mapcar (lambda (x)
- [Erbot-cvs] erbot erbtranslate.el ChangeLog,
Vivek Dasmohapatra <=