unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Dr. Arne Babenhauserheide" <arne_bab@web.de>
To: 54139@debbugs.gnu.org
Subject: bug#54139: 27.2; Translating the Emacs Menu
Date: Thu, 24 Feb 2022 09:30:34 +0100	[thread overview]
Message-ID: <875yp4ll22.fsf@web.de> (raw)

[-- 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 --]

             reply	other threads:[~2022-02-24  8:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24  8:30 Dr. Arne Babenhauserheide [this message]
2022-02-24  9:34 ` bug#54139: 27.2; Translating the Emacs Menu Lars Ingebrigtsen
2022-03-26 16:37   ` Lars Ingebrigtsen
2022-03-26 22:43     ` Dr. Arne Babenhauserheide

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yp4ll22.fsf@web.de \
    --to=arne_bab@web.de \
    --cc=54139@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).