From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "pelzflorian (Florian Pelz)" Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: Website translations with Haunt Date: Wed, 13 Dec 2017 15:53:33 +0100 Message-ID: <20171213145332.v4apawqfsc2b47dp@floriannotebook> References: <20171209180619.GA10254@floriannotebook.localdomain> <20171209181529.xzpfpjl4y4ugrqhv@abyayala> <20171209210857.GA1064@floriannotebook.localdomain> <20171209222949.2swclhnlz6kmtj5a@abyayala> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pzhhljmfcmy5dci5" X-Trace: blaine.gmane.org 1513176824 19580 195.159.176.226 (13 Dec 2017 14:53:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 13 Dec 2017 14:53:44 +0000 (UTC) User-Agent: NeoMutt/20171208 To: Guile User , guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Dec 13 15:53:37 2017 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eP8Pf-0004a7-37 for guile-devel@m.gmane.org; Wed, 13 Dec 2017 15:53:35 +0100 Original-Received: from localhost ([::1]:35839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP8Pl-0002Wz-Qj for guile-devel@m.gmane.org; Wed, 13 Dec 2017 09:53:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP8Pc-0002Wu-8s for guile-devel@gnu.org; Wed, 13 Dec 2017 09:53:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eP8PY-0007mi-8s for guile-devel@gnu.org; Wed, 13 Dec 2017 09:53:32 -0500 Original-Received: from pelzflorian.de ([5.45.111.108]:54252 helo=mail.pelzflorian.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eP8PX-0007m1-Qc; Wed, 13 Dec 2017 09:53:28 -0500 Original-Received: from floriannotebook (eduroam-ipv4-4-0199.triple-a.uni-kl.de [131.246.176.199]) by mail.pelzflorian.de (Postfix) with ESMTPSA id A3195360072; Wed, 13 Dec 2017 15:53:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pelzflorian.de; s=mail; t=1513176805; bh=iWeXisLzI/yDtUst3JLovOhPK6+e2BzoNtrCAuvGVlo=; h=Date:From:To:Subject:References:In-Reply-To; b=llRr1AUrjOJigmu+GiM5U3uFmo2O/r65qLgd7VsufSPCpSJHA+Q8gdHIBsxcXOr/F LsbSVHSkp1o8+rlti/skyB88kIb7Nd8v7ttYKPTLrK+bMoBmUCP+GLygkLQD9kQhAk YRXXgCEvxemS6I5x+dC7L7+IkqHoY3rfN4s+gCU8= Content-Disposition: inline In-Reply-To: <20171209222949.2swclhnlz6kmtj5a@abyayala> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 5.45.111.108 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19421 gmane.lisp.guile.user:14345 Archived-At: --pzhhljmfcmy5dci5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Dec 09, 2017 at 10:29:49PM +0000, ng0 wrote: > pelzflorian (Florian Pelz) transcribed 2.4K bytes: > > On Sat, Dec 09, 2017 at 06:15:29PM +0000, ng0 wrote: > > > My idea was a reimplementation of prep (a text format and html docume= nt > > > generator that is capable to include multiple languages in its source > > > files, written by lynX back in the early 90s (or earlier) iirc (and > > > still used today). > > > > >=20 > > Hmm I can find neither prep nor lynX in a quick Web search. >=20 > lynX is the author of many things, among them the psyc and psyc2 protol, > psyced, the /me command in IRC etc. this page is generated from prep: htt= p://my.pages.de > (http://my.pages.de/me should show more). >=20 I see. lynX deserves a better Duckduckgo search ranking than he has. ;) There is a lot to look at; thank you for the link. I now also understand better what kind of organization youbroketheinternet is. Either way, > > Po files are separate from the source code files. I don=E2=80=99t know= if > > prep has such a separation or if such a separation really is better. > >=20 > > Then again, another issue with HTML/SHTML is that e.g. a hyperlink with= in > > the text is difficult to handle with traditional format strings > > without breaking the separation: > >=20 > > * The link text should be translated in the context of the text > > surrounding the link > >=20 > > * but the link formatting and maybe the link destination URL maybe > > should not be changeable by the translator. > >=20 > > Does prep handle this? >=20 > To some extent. prep is not SGML. It's been a while since I've looked > into it but basically you have a unique syntax. The following snippet > (from pages/my/convivenza.mlm) doesn't show it's full usage, > but it show how links are handled: >=20 >=20 > I)#section Approfondimenti > D)#section Vertiefung > E)#section Further Reading >=20 > [=E2=80=A6] > To my best knowledge nothing has been developed that allows to convenient= ly > define multiple languages in one source file outside from plain S/XML, and > this is what I find interesting about prep. Wether I end up writing a rei= mplementation > in Guile or not, there are some interesting ideas that could possibly be = applied > to your approach. > I'll need some time to find time to compare the two approaches and find s= imilarities. >=20 > Maybe my reply already helps, with reading the provided (really small) co= debase > of prep. > Thank you, I looked at it. This is certainly interesting but combining SHTML and translation in one file is not what I want. I agree that it has advantages, but I have settled on this for now: (define (paragraph-about-a-manatee-for-lingua lingua) (let* ((current-lingua lingua)) `(p ,@(__ "img1|This|| is an image of a ||link1|https://en.wikipedia.org/= wiki/Manatee|manatee||." `(("img1" . ,(lambda (text) `(img (@ (src "https://upload.wikimedia.org/wikipedia/com= mons/thumb/0/05/Bair%27s_Cove_-_Haulover_Canal%2C_Merritt_Island_FL_-_Flick= r_-_Rusty_Clark_%2833%29.jpg/320px-Bair%27s_Cove_-_Haulover_Canal%2C_Merrit= t_Island_FL_-_Flickr_-_Rusty_Clark_%2833%29.jpg") (alt ,text))))) ("link1" . ,(lambda (url text) `(a (@ (href ,url)) ,text)))))))) I implemented it like this: (define translated-msg ;; gettext is not used directly because it would require repeated ;; setlocale calls, which should not be necessary. ;; See: https://stackoverflow.com/questions/3398113/php-gettext-problems (let [=E2=80=A6] (lambda (msgid lingua) "Returns the msgstr for MSGID from the po file for LINGUA." [=E2=80=A6]))) (define (translated-multipart-msg msg lingua assoc) "Looks up MSG for LINGUA via Gettext and returns a list of its parts. Parts are separated by two vertical bars ||. If a part is prefixed by a text followed by a vertical bar the text is looked up a lambda in the association list ASSOC. If found, the lambda is called on the remainder of the part and the result added to the list. If it is not found or there is no vertical bar, the entire part is added to the list." (define (split-along-unescaped-matches str pattern) "Splits along pattern unless pattern is escaped by a backslash." (let loop ((remainder str) ; what to match with (start 0)) ; where to start matching, used to ignore escaped= matches (let ((match (string-match pattern remainder start))) (if match ; if there is a match: (if (and ;; if match not at the beginning (not (=3D (match:start match) 0)) (eq? ; and escaped by a backslash (string-ref remainder (- (match:start match) 1)) #\\)) ;; then continue matching after the escaped match: (loop (string-append ; the same as remainder but (string-drop-right (match:prefix match) 1) ; drop backsla= sh (match:substring match) (match:suffix match)) (- (match:end match) 1)) ;; otherwise: (cons ;; everything before the match (match:prefix match) (loop ; recursive call (match:suffix match) ; on everything after the match 0))) ; start matching at start ;; if pattern did not match: (list remainder))))) (let ((msgstr-parts (split-along-unescaped-matches (translated-msg msg lingua) "\\\|\\\|"))) (map (lambda (msgstr-part) (let* ((subparts (split-along-unescaped-matches msgstr-part "\\\|")) (part-lambda (assoc-ref assoc (car subparts))) (args (cdr subparts))) (if part-lambda (apply part-lambda args) msgstr-part))) msgstr-parts))) (define-syntax __ (lambda (x) "Gettext shorthand for multipart messages separated by || in the string= =2E" (syntax-case x () ((__ msg assoc) (with-syntax ((current-lingua (datum->syntax x 'current-lingua))) #'(translated-multipart-msg msg current-lingua assoc)))= ))) Regards, Florian --pzhhljmfcmy5dci5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEwRjGsqAMqXB4uw3y3T6EbElHBVsFAloxPuUACgkQ3T6EbElH BVt/txAAhzJZBwt2bH9tn9KwZvOfru9bFv648i83gs4dqzcs7snUlv08Mu4lP+mD 4wE+fgvHSnx1zGsFVAJr0kX9kdZQp3/9hcEfgUrKeDLhnq4o4o6uMcp3X7CTUbQW PTeLXKmnY5fSihbCbvSefnG6TAx9AVr6eco4V6mpoLCqJlVWXJBHDzusb9ZokAty XjOxfrIeNW2qll4m6lhXb0kW7RsP1tiLfD0ymZ17BgviJOVrWYgCb5Wsjfb3YEgC ezA2ideBR0vW2LtxWf85FFfW1WIHLuZmm1Tku4mXITFLdglT/pGn2UIumU5f/XkO YBLv5w9Ti/TXcgkDFz53zvBCUfRds6a49CoiFaGyktOLnyhXqz7FkjSxxygVK5vU OS5hkRMARqBrpmyI+Ww8zpjA0koEO60fC8Jnp6gAnKWNlreWNnFfYQHaV8AvgbdY 9qH+DIdggK9oF9Emr0hcHLan8Bo4N/I5v11CGMF0k7dTyxE67OnDqxRlr03x5I3a yNU+S6efURbOMd1I7RXtWXC9HBDPXJ/LyyjwX/sjzmZlhjT6BDjunxRCrq6dabzk fMfKcCKV7Nndol3M1njtTs2hjYXxHmPWt/egXJNvQZT+blYYkmz/6xMbXjhnJ+rX Teub13CghU0tuq/8DuoxRxmQACMvH0Okiv1I1xuQBPoS5lWJ+7o= =r0ss -----END PGP SIGNATURE----- --pzhhljmfcmy5dci5--