From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#34520: delete-matching-lines should report how many lines it deleted Date: Sat, 02 Mar 2019 22:55:52 +0200 Organization: LINKOV.NET Message-ID: <871s3p0zdz.fsf@mail.linkov.net> References: <87o97aq6gz.fsf@jidanni.org> <87tvgoud56.fsf@mail.linkov.net> <83o96wk2mi.fsf@gnu.org> <87k1hjfvjd.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="108520"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 34520@debbugs.gnu.org, jidanni@jidanni.org To: Richard Stallman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 02 22:27:40 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h0CAT-000S3V-S7 for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Mar 2019 22:27:38 +0100 Original-Received: from localhost ([127.0.0.1]:59076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0CAS-0005UZ-Ry for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Mar 2019 16:27:36 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0C8x-0004PT-8a for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2019 16:26:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0C8w-0002Dp-Fb for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2019 16:26:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h0C8w-0002Cp-AV for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2019 16:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h0C8v-0004LW-LZ for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2019 16:26:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Mar 2019 21:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34520 X-GNU-PR-Package: emacs Original-Received: via spool by 34520-submit@debbugs.gnu.org id=B34520.155156193816666 (code B ref 34520); Sat, 02 Mar 2019 21:26:01 +0000 Original-Received: (at 34520) by debbugs.gnu.org; 2 Mar 2019 21:25:38 +0000 Original-Received: from localhost ([127.0.0.1]:57922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0C8X-0004Kj-UL for submit@debbugs.gnu.org; Sat, 02 Mar 2019 16:25:38 -0500 Original-Received: from bisque.maple.relay.mailchannels.net ([23.83.214.18]:30665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h0C8U-0004KU-Ts for 34520@debbugs.gnu.org; Sat, 02 Mar 2019 16:25:36 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6A11F5C4A41; Sat, 2 Mar 2019 21:25:32 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a27.g.dreamhost.com (unknown [100.96.36.131]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 072245C4851; Sat, 2 Mar 2019 21:25:32 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a27.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.3); Sat, 02 Mar 2019 21:25:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Average-Broad: 5d78de415189f787_1551561932255_4065775607 X-MC-Loop-Signature: 1551561932255:1300030879 X-MC-Ingress-Time: 1551561932254 Original-Received: from pdx1-sub0-mail-a27.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a27.g.dreamhost.com (Postfix) with ESMTP id A736C80452; Sat, 2 Mar 2019 13:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=linkov.net; bh=ijanWA vPKhnH4bZtOSL89NY30fY=; b=C6P0XOlXs4+7p7GO9E96W32qGjgp2bIoxQJ71X WRfks/H8CQzLiGanHfzEmxKVjWmeWubTqDqRZXkspJHLlcDGZysQ21JV8HJLp892 s+loUELedFCj8ddfUywk7iNIYRVLO9oBUnlRa69V5ksE5lKBISdWd8bQ3FiMDQdr /A7qg= Original-Received: from mail.jurta.org (m91-129-98-103.cust.tele2.ee [91.129.98.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a27.g.dreamhost.com (Postfix) with ESMTPSA id 3F1C480442; Sat, 2 Mar 2019 13:25:28 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a27 In-Reply-To: (Richard Stallman's message of "Thu, 28 Feb 2019 22:59:17 -0500") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrvdejgdduheefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuohhfffgjkfgfgggtgfesthekredttderjeenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrdelkedruddtfeenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrdelkedruddtfedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehrmhhssehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:155976 Archived-At: > > Ok, waiting for the times when =E2=80=98gettext=E2=80=99 will arriv= e 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 (=3D 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-strin= g 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.