From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: sirgazil Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: Website translations with Haunt Date: Sat, 16 Dec 2017 10:26:12 -0500 Message-ID: <7e3a3109-25c5-ed60-9a7b-ee1a656de87e@zoho.com> References: <20171209180619.GA10254@floriannotebook.localdomain> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1513501126 15279 195.159.176.226 (17 Dec 2017 08:58:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 17 Dec 2017 08:58:46 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 To: "pelzflorian (Florian Pelz)" , Guile User , guile-devel Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Dec 17 09:58:42 2017 Return-path: Envelope-to: guile-user@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 1eQUmM-0003KN-75 for guile-user@m.gmane.org; Sun, 17 Dec 2017 09:58:38 +0100 Original-Received: from localhost ([::1]:53590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQUoI-0005SP-NU for guile-user@m.gmane.org; Sun, 17 Dec 2017 04:00:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQUns-0005Qq-Pa for guile-user@gnu.org; Sun, 17 Dec 2017 04:00:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQUnp-0007lr-Mn for guile-user@gnu.org; Sun, 17 Dec 2017 04:00:12 -0500 Original-Received: from sender-pp-092.zoho.com ([135.84.80.237]:25326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eQUnp-0007kn-DM for guile-user@gnu.org; Sun, 17 Dec 2017 04:00:09 -0500 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=subject:to:references:from:message-id:date:user-agent:mime-version:in-reply-to:content-type; b=HRI4/6zjPXOengciXz/7XRt0uwa+koiHexJV+xxtjmNPMG0Jdvpm2T7Fk5rN1v59sJAGDZ9PpR2V b+kqtbFcKntuX8f+i7HvHFuTR8kf5AMnP04VkmJq0V9llxlcBgo0 Original-Received: from [192.168.1.51] (190.251.129.76 [190.251.129.76]) by mx.zohomail.com with SMTPS id 1513437974795925.1872816441245; Sat, 16 Dec 2017 07:26:14 -0800 (PST) In-Reply-To: <20171209180619.GA10254@floriannotebook.localdomain> Content-Language: en-US X-ZohoMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 135.84.80.237 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14377 gmane.lisp.guile.devel:19442 Archived-At: Hi :) On 09/12/17 13:06, pelzflorian (Florian Pelz) wrote: > Hello, > > First of all, I want to say thank you to the Guile, Haunt, ffi-helper > and related projects’ developers. > > I built my personal website [1] using David Thompson’s Haunt [2] and > recently talked my university’s Islamic Students’ Association > (Islamische Hochschulvereinigung) into using Haunt for their > not-yet-finished website as well, because I think the concept of Haunt > and SHTML is superior to alternatives. However in order to make the > website multilingual (the user can choose to view it in German or > English) so far I used an association list with assoc-ref which is not > very comfortable since all strings have to be added in two places, > i.e. in the SHTML code and in the association list where the code > looks for translations. > > I want to ask for your thoughts on my new solution since translations > are probably important to many Haunt users. In particular, I believe > there was some discussion on Website translation on the Guile or Guix > lists as well. I'm very interested on this subject because I help with Guile and Guix websites, and I usually work with multilingual websites. I have no idea of what would be the right way to do i18n of websites written in Scheme, though. So I will just join this conversation as a potential user of your solutions :) > I did not want to use the ordinary gettext functions in order to not > call setlocale very often to switch languages. It seems the Gettext > system is not designed for rapidly changing locales, but maybe I am > wrong about this and very many setlocale calls would not be that bad. For what is worth, I use ordinary gettext and `setlocale` in my website, which is not Haunt-based, but it is Guile Scheme and statically generated too. So far, it works ok. For internationalization, I know the convention is to use _, but I don't like that, so I use the alias l10n instead. For internationalizing complex blocks that should not be translated in fragments, like: `(p "Hi! I play " (a (@ (href ,sport-url)) ,(l10n "futsal")) " in " (a (@ (href ,place-url)) ,(l10n "Tokyo"))) I had to write a procedure I call `interleave` that I use like this: `(p ,@(interleave (l10n "Hi! I play ~SPORT~ in ~PLACE~.") `(a (@ (href ,sport-url)) ,(l10n "futsal")) `(a (@ (href ,place-url)) ,(l10n "Tokyo")))) So, in the translation catalogs, translators will see the strings: "Hi! I play ~SPORT~ in ~PLACE~." "futsal" "Tokyo" Currently, I use xgettext manually and Poedit for working with translation catalogs, but I'd like to manage translations in the future like this (replace `site` with `haunt`): # Create new translation catalogs for Finnish and Japanese. $ site catalog-new fi ja # Update translation catalogs with new translation strings. $ site catalog-update # Compile translation catalogs (generate .mo files) $ site catalog-compile To be fully localized, I also have to pass IETF Language Tags around in the website code, so that I get the right content when rendering the templates in a given language. My 2¢