(ideo-translate-region-into-traditional): New command.
authortomo <tomo>
Wed, 5 Nov 2003 15:19:34 +0000 (15:19 +0000)
committertomo <tomo>
Wed, 5 Nov 2003 15:19:34 +0000 (15:19 +0000)
ideo-trans.el

index 4f50ce8..5055791 100644 (file)
 (define-obsolete-function-alias 'ideo-trans-simplify-chinese-string
   'ideo-translate-string-into-simplified-chinese)
 
+;;;###autoload
+(defun ideo-translate-region-into-traditional (start end)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region start end)
+      (goto-char start)
+      (let (chr ret rret i prompt)
+       (while (and (skip-chars-forward "\x00-\xFF")
+                   (not (eobp)))
+         (setq chr (char-after))
+         (if (setq ret (or (get-char-attribute chr '<-simplified@jp-jouyou)
+                           (get-char-attribute chr '<-simplified@jp)
+                           (get-char-attribute chr '<-jp-simplified)))
+             (progn
+               (if (cdr ret)
+                   (progn
+                     (setq i 0)
+                     (setq prompt
+                           (concat
+                            (mapconcat (lambda (cell)
+                                         (setq i (1+ i))
+                                         (format "%d. %c" i cell))
+                                       ret " ")
+                            " : "))
+                     (while (and (setq rret
+                                       (string-to-int
+                                        (read-string prompt)))
+                                 (not (and (< 0 rret)
+                                           (<=  rret (length ret))))))
+                     (delete-char)
+                     (insert (nth (1- rret) ret)))
+                 (delete-char)
+                 (insert (car ret))))
+           (or (eobp)
+               (forward-char))))))))
+
 
 ;;; @ End.
 ;;;