bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#54139: 27.2; Translating the Emacs Menu


From: Dr. Arne Babenhauserheide
Subject: bug#54139: 27.2; Translating the Emacs Menu
Date: Thu, 24 Feb 2022 09:30:34 +0100
User-agent: mu4e 1.6.10; emacs 27.2

For newcomers the Menu is very useful to start into Emacs. But it is
only available in English.

It would be great to be able to translate it, for example by setting
some translation strings.

One way to get the initial steps could be to have (bindings--define-key
...) check a table of known translations and use a translated string if
available.

A more advanced method would be shelling out to gettext to benefit from
existing translation platforms.

Here’s an unclean proof of concept that might break your Emacs and is
not fit for Emacs itself due to using advice:

(defun translate-bindings (orig-fun &rest args)
  (let* ((menu (nth 0 args))
         (key (nth 1 args))
         (entry (nth 2 args))
         (new-entry (cond
                     ((and (< 1 (length entry)) (stringp (nth 0 entry)))
                      (let ((name (nth 0 entry)))
                        (cons (concat "translated: " name) (cdr entry))))
                     ((and (< 2 (length entry)) (stringp (nth 1 entry)))
                      (let ((name (nth 1 entry)))
                        (cons (car entry) (cons (concat "translated: " name) 
(cdr (cdr entry))))))
                     (t entry))))
    (print (and (< 2 (length entry)) (stringp (nth 1 entry))))
    (print new-entry)
    (apply orig-fun menu key (list new-entry))))
(advice-add 'bindings--define-key :around #'translate-bindings)
(require 'menu-bar)
(bindings--define-key global-map [menu-bar edit]
   (cons "Edit" menu-bar-edit-menu))

Best wishes,
Arne


-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]