unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54139: 27.2; Translating the Emacs Menu
@ 2022-02-24  8:30 Dr. Arne Babenhauserheide
  2022-02-24  9:34 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Dr. Arne Babenhauserheide @ 2022-02-24  8:30 UTC (permalink / raw)
  To: 54139

[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]


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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-26 22:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-24  8:30 bug#54139: 27.2; Translating the Emacs Menu Dr. Arne Babenhauserheide
2022-02-24  9:34 ` Lars Ingebrigtsen
2022-03-26 16:37   ` Lars Ingebrigtsen
2022-03-26 22:43     ` Dr. Arne Babenhauserheide

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).