GNU bug report logs -
#34520
delete-matching-lines should report how many lines it deleted
Previous Next
Full log
Message #25 received at 34520 <at> debbugs.gnu.org (full text, mbox):
> > Ok, waiting for the times when ‘gettext’ will arrive to Emacs.
>
> It would be very desirable to make Emacs support gettext-style
> translations. I have a feeling that it can't use the same
> code as gettext -- but with all of Emacs's other facilities,
> I think that transposing the useful part of gettext into
> Emacs won't be a big job.
>
> Would someone like to do this?
Emacs can do much better job of text translation than gettext.
It's easy to translate text transparently to the caller,
i.e. without changing the caller code at all, by adding
a new intermediate layer to some text output functions
that will translate their string arguments to the
language of the default language environment.
Here is an experimental but extensible implementation
that handles the case of formatting the recently added message
taking into account grammatical number of its argument:
(defvar i18n-translations-hash (make-hash-table :test 'equal))
(defun i18n-add-translation (_language-environment from to)
(puthash from to i18n-translations-hash))
(i18n-add-translation
"English"
"Deleted %d matching lines"
(lambda (format-string count)
(if (= count 1)
"Deleted %d matching line"
"Deleted %d matching lines")))
(defun i18n-get-translation (format-string &rest args)
(pcase (gethash format-string i18n-translations-hash)
((and (pred functionp) f) (apply f format-string args))
((and (pred stringp) s) s)
(_ format-string)))
(advice-add 'message :around
(lambda (orig-fun format-string &rest args)
(apply orig-fun (apply 'i18n-get-translation format-string args) args))
'((name . message-i18n)))
In addition to translating format strings of the function 'message',
doing the same for more text output functions like 'describe-function',
'describe-variable' and 'menu-item' in 'define-key' would cover most
of the internationalization needs.
This bug report was last modified 6 years and 139 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.