[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: running gettext() in wasm
From: |
Vivien Kraus |
Subject: |
Re: running gettext() in wasm |
Date: |
Sat, 21 Dec 2024 20:56:04 +0100 |
User-agent: |
Evolution 3.48.4 |
Le samedi 21 décembre 2024 à 16:33 +0100, Bruno Haible a écrit :
> Two thoughts on this:
>
> * Your page says that the purpose is to run code "on Wasm GC-
> capable
> web browsers".
> Whereas the .mo files were designed to run code on platforms with
> a
> POSIX file system, especially with mmap.
>
> How do you intend to map the file system to the web browser
> model?
> Will the server send the entire file system (with all *.mo files)
> to the client? Or will the server only send the one or two
> relevant
> .mo files (say, fr_CA.mo and fr.mo for users in Quebec) to the
> client?
I am actually working on a compile-time Guile macro that will
statically put all the known translation in the webassembly near each
site where translation is requested:
https://labo.planete-kraus.eu/guile-static-i18n.git
So the translations end up in a similar way to resources that you would
bundle in an executable. There is no need for a file system or extra
requests. It’s better than resources, because each translation is
integrated in code at the call site where it may be used, so there is
no need to parse mo files at run-time.
You could also view it as a code generator that would generate
different locale-specific versions of a function with string literals
replaced with their translations in the specific locale. It would be a
horrible thing to do in C, but metaprogramming is a strength of Scheme.
It is less flexible than Gettext, because I can’t update the
translations without recompiling the program for instance, but I don’t
do that on the desktop anyway. Also, see how Gettext lets you embed
translations in .desktop files for instance. You can’t change them
without regenerating the .desktop file.
It may make bigger executables, but that’s only a distant concern of
mine for now.
>
> * The native data format in web browsers is JSON. Why not convert
> a PO file to a JSON file, instead of .mo, and send that to the
> browser?
> That would not need any Scheme code on the client, right?
I prefer to turn the PO files into Scheme syntax that I can use in my
code, and I find the MO files to be a nice intermediate step in this
process. I would rather stay away from browser-specific things if
possible.
Vivien