unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Nala Ginrut <nalaginrut@gmail.com>
To: Vivien Kraus <vivien@planete-kraus.eu>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Static, pure Scheme internationalization
Date: Sat, 21 Dec 2024 20:18:19 +0900	[thread overview]
Message-ID: <CAPjoZofNjy0GxAyX7kibo4AWWJ59omi2da7rpAWYLQE4wfbsdw@mail.gmail.com> (raw)
In-Reply-To: <a841daffe1287658fd73e447af16739294889176.camel@planete-kraus.eu>

Hi Vivien!
I'm also interested in Hoot for potential web frontend in Scheme.

Back to your case, as I understand, Hoot reused part of Guile code, include
i18n.
Maybe not complete yet, but it contains gettext, and G_ is its short hand.

I saw you implemented a simple G_ macro, is there any reason that it can't
meet your requirements? Or you just happend to not know it exited in Hoot?

Best regards.
Best regards.

On Sat, Dec 21, 2024, 18:31 Vivien Kraus <vivien@planete-kraus.eu> wrote:

> Dear Guile users,
>
> I am very excited about Hoot, but there is one aspect I was not
> satisfied with: internationalization. Since it is usually done with
> gettext, it requires a C library at run-time. Hoot programs can’t
> unfortunately use that.
>
> With your help, I managed to understand how I could rewrite code with
> macros.
>
> Thanks to this knowledge, I was able to create a small library for
> static and pure Scheme internationalization.
>
> It works like this
> (https://labo.planete-kraus.eu/guile-static-i18n.git/tree/example.scm):
>
> (define-module (example)
>   #:use-module (static-i18n)
>   #:declarative? #t
>   #:export (main))
>
> ;; We have to tell where the pot file lives at expansion time.
> (eval-when (expand)
>   (project-pot-file
>    (string-append (dirname (current-filename)) "/example.pot"))
>   (project-po-directory
>    (string-append (dirname (current-filename)) "/example-po")))
>
> ;; collect-strings updates a PO template file, regenerates PO files,
> ;; and use them to provide translations for any calls to G_.
> (collect-strings
>  ;; This is defined at the top-level.
>  (define (main args)
>    ;; current-locale-order is parameterized by a list of locale names
>    ;; to try in order.
>    (parameterize ((current-locale-order '("de" "fr" "en")))
>      ;; Note how you can use (G_ context message) to register a new
>      ;; record, without having to call xgettext.
>      (format #t (G_ "GREETING" "Hello, world!~%")))))
>
> (main (command-line))
>
> Once expanded, every call to G_ will have all possible translations
> compiled in, and the correct one will be chosen according to a list of
> preference for the user (a run-time Guile parameter).
>
> The big downside is, it doesn’t support plurals. However, I believe it
> can be useful!
>
> https://labo.planete-kraus.eu/guile-static-i18n.git
>
> Best regards,
>
> Vivien
>
>


  reply	other threads:[~2024-12-21 11:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-21  9:30 Static, pure Scheme internationalization Vivien Kraus
2024-12-21 11:18 ` Nala Ginrut [this message]
2024-12-21 11:46   ` Vivien Kraus
2024-12-21 12:14     ` Nala Ginrut
2024-12-21 12:36       ` Nala Ginrut
2024-12-21 14:15         ` Vivien Kraus
2024-12-21 14:18           ` Nala Ginrut
2024-12-21 14:31             ` Vivien Kraus
2024-12-21 18:27               ` Nala Ginrut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPjoZofNjy0GxAyX7kibo4AWWJ59omi2da7rpAWYLQE4wfbsdw@mail.gmail.com \
    --to=nalaginrut@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=vivien@planete-kraus.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).