From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Brooks Newsgroups: gmane.emacs.devel Subject: Re: making gettext more like fluent Date: Sun, 27 Dec 2020 22:30:33 -0800 Message-ID: <87bleeqw6u.fsf_-_@db48x.net> References: <87o8ivumn5.fsf@telefonica.net> <83sg7xrgr5.fsf@gnu.org> <83h7odrdwy.fsf@gnu.org> <86sg7w39fh.fsf@163.com> <83pn30pku5.fsf@gnu.org> <86wnx8otoj.fsf@163.com> <834kkbp9vr.fsf@gnu.org> <87czyxuxw6.fsf@db48x.net> <87v9cosv0b.fsf@db48x.net> <877dp3skh8.fsf@db48x.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9114"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: all_but_last@163.com, bugs@gnu.support, dimech@gmx.com, abrochard@gmx.com, emacs-devel@gnu.org, eliz@gnu.org To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 28 07:32:08 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ktm4d-0002Hg-SA for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Dec 2020 07:32:07 +0100 Original-Received: from localhost ([::1]:49800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktm4c-0004v3-Rp for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Dec 2020 01:32:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktm3O-0004TU-BE for emacs-devel@gnu.org; Mon, 28 Dec 2020 01:30:50 -0500 Original-Received: from smtp-out-4.mxes.net ([2605:d100:2f:10::315]:57323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktm3H-00005J-72 for emacs-devel@gnu.org; Mon, 28 Dec 2020 01:30:48 -0500 Original-Received: from Customer-MUA (mua.mxes.net [10.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTPSA id CF37675983; Mon, 28 Dec 2020 01:30:35 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mxes.net; s=mta; t=1609137038; bh=Dyj9rhB2prfZDTM9jd7QNQt4/arbfGwp+J+WNYbt51w=; h=From:To:Subject:References:Date:In-Reply-To:Message-ID: MIME-Version:Content-Type; b=Gy70Bpzt9YfTcFXNCXYERE2PddzjiXf6PpS/pY+rKVU2ZhUUSzu6TYL69jEpHU5ck CT+MJmDnooEKuGcTL/OxgPI9lCwee+hulRbdlJb517+jOTSk8lf+O9t+NRjIoW8+gf 8+Vt/4QHH5xwIv+O6e+6ZCpRmpjEgmU6fX8Z3hOk= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGOfPtRkwAAABJQ TFRFpKfbdou67PD6JjJgAwUWXGSeIcyLHgAAAkZJREFUOI1VU8Fy6yAMxLi+Q13fCZ3cnQL3dqTc 7RD+/1feStDXVnXHDuvVSivZTMba2GPdw3gyCGcMAFxTyrTd9dwGoxHiZX9PmRFUHYAQlGGtXY+F Uk0SJOxgJiUEnH1qkitT9D+pQub7qGAmUbR6bu3CvI96Yv6QqkBBMrsyfZccr1/RDXGDTLf4P7ZY glVxe2V+/ACXWO1gvDO9/gDRpFFVmPluvLcmBjd5H6d8DEte+Pbk4rcY/Fa5tLKLOtCZsuQKYhpa LOkYDT7hESya7/WIET3lfQBqX0pwFtbI832Is0ayMUR9B+12xjgPCQ089cfwkCkX6L5TPmRelJTh zMS0Sz1PyjLAMCUWjcmgQLWQMds+e3aaauZDf9dU9A2/8kPVF2odCUoMKHkfjJR+mbgC+DRiycw5 3XSqGe6HmhN/AWjHypkAXOAFW5EiuA1ge2GiZuMb0s1fSEXcATeLUfbyEY2L8yPOmdSsdghQXx3K pz2eoeXuYvMCINVFDrCdNfVUp4eJ6cSEbjbgFjBEvonGGTrgv9cHjAc8aVgSAPoxaONbzfwhDIhR at7IIS7fAGiDSwIA9alhhTBzfA7YM2FY6eMwayrIGK8FDFmshmUA43WqhFtpvoqG9HHaJ7fqtgTz 8EWVkgZgtsylFliHDgk0MB7KAEC45C/rgnGvanNLXyzOeTzcT2nw/N44gfrtYXRQLoz9Q3TgmJRx 2Mx/Q51qzpm+l3m8z2SWBqC5+PZXAtNYlGFf/gKfHfjFkDT4x7od7R+w3Ls+ZdQBuQAAAABJRU5E rkJggg== In-Reply-To: (Richard Stallman's message of "Mon, 28 Dec 2020 00:28:44 -0500") X-Sent-To: Received-SPF: none client-ip=2605:d100:2f:10::315; envelope-from=db48x@db48x.net; helo=smtp-out-4.mxes.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:261982 Archived-At: Richard Stallman writes: > > > Is it feasible to write a small Fluent interpreter in C for this > > > purpose? > > > Absolutely, but my personal preference is to write it in Elisp. > > An implementation in Elisp could be ok for Emacs, but Emacs is just > one of hundreds of GNU packages, and one of thousands of packages in > the GNU system. > > To fully adopt Fluent along with gettext as the GNU method of handling > this, we need to make it work in C programs. The only simple, clean > and general way is to implement it in C. > > Maintainers will never adopt this if their programs need to link > with Emacs or with Rust. Certainly most programs cannot link to Emacs; Emacs isn't even designed for that. Rust _is_ designed to be linked with C programs, and it is an excellent language to write things in. It is only my opinion, but Rust is a significant long-term threat to the ubiquity of GCC. Another similar threat is the low quality of the C language itself. To counter this, GCC should grow a Rust front-end. I hope that the work has already begun. But that is a topic for a different day. I would not volunteer to write any large amount of C. I know C, and am good enough with it, but suffering the aggravations of the language is not my idea of a good time. Again it's just my opinion, but Emacs could link against Rust code such as fluent-rs if we wanted it to. The Rust compiler is free software, and has become readily available in most Linux distributions. There are no technical roadblocks either. I have no idea what it would take for people to want it, but I'd volunteer to help if they did. > > The message catalog files (MO files) just have flat strings with no > > notion of substitutions or function calls. This is why my first > > inclination was to generate elisp code from a Fluent file. > > I don't follow how the beginning leads to the conclusion. My apologies. It seems that I stated some of my conclusions and then followed them up with supporting examples. > > The easiest way to mush gettext and fluent together is to put some > > syntax into the messages that is post-processed before being returned to > > the caller, turning it into an interpreter. > > That is too terse for me -- I am totally list. > > > Something like this in a PO file: > > > msgid "-sync-brand-name" > > msgstr "Firefox Account" > > > msgid "sync-signedout-title" > > msgstr "Connect with your {-sync-brand-name}" > > I see what it says, but can you explain how that relates to "syntax > that is post-processed before being returned to the caller"? Terse > references such as "the caller" leave me lost because I can't tell > what they refer to. The leap is too long for me to follow. The caller is some part of Emacs, let's say. Emacs calls the hypthetical igettext("sync-signedout-title"), and the translator wants Emacs to get the string "Connect with your Firefox Account" (I've just copied this example from projectfluent.org, which got it from the Firefox source code). With this simple proposed syntax, igettext must inspect each string that it retrieves from the message catalog to see if it contains any substitutions. Those substitutions can be almost as recursive as a real lisp program, and they can have conditional statements like lisp programs. Thus I would prefer to just compile the Fluent syntax into Lisp functions rather than to write a new interpreter. One build step for Emacs would be to read in the Fluent files for all available translations, and output ordinary .el files. Those .el files would then be loaded during the bootstrap process, just like all the existing lisp source files. It occurs to me that one way to refine this a little bit would be to directly output a elisp bytecode to a .elc file after reading in a Fluent file. This skips a step, and makes distributing packages containing translations easier. Making `load' recognize Fluent files seems like it would tie everything up nicely. > > Also, note that the original language wants to have the same > > substitution capabilities as the translations. > > What does "the original language" mean here? Whatever language the user interface was originally written in. In the case of Emacs, this is English. The English "translation" of Emacs will want to use the same Fluent capabilities that any translation would have access to. db48x