For what it's worth, Learn-OCaml [1] uses a rather straightfoward way to handle translations through PPX, based on the gettext format. It's a quick hack and the build-system around it could use some cleanup, though, which is the reason why it wasn't released as a library: please consider it a proof of concept that PPX can be used for gettext. - Translatable strings are introduced through [%i "Blah" ] (or [%if "Blah"] for format-strings; advanced uses like changing format parameters order are not supported) - The build extracts these to a separate file at build-time, based on an environment variable `DUMP_POT` [2]. Probably the most dirty part here, and it requires a clean build, but it works... - Then the standard GNU tools can be used to manage the translations [3] - There is a tiny library at runtime that allows choosing the locale; located strings are rewritten to arrays with a lookup based on it (but changing that to something more elaborate like using external resource files should be pretty straightforward) [4]. Louis Gesbert -- OCamlPro [1] https://github.com/ocaml-sf/learn-ocaml/ [2] https://github.com/ocaml-sf/learn-ocaml/blob/master/src/utils/ppx_ocplib_i18n.ml [3] https://github.com/ocaml-sf/learn-ocaml/blob/master/Makefile#L33 [4] https://github.com/ocaml-sf/learn-ocaml/blob/master/src/utils/ocplib_i18n.mli > - Richard W.M. Jones, 29/06/2019 10:43 - > On Sat, Jun 29, 2019 at 10:06:15AM +0100, Anil Madhavapeddy wrote: > > On 27 Jun 2019, at 14:45, Richard W.M. Jones wrote: > > > > > > > > > I know camlp4 is dead and all that, but we've got some software which > > > still uses it. I will probably port it to camlp5 when I have the > > > time, but has anyone got the patch to make camlp4 work with 4.08? > > > > > > To fork the thread slightly, how big are the camlp4 dependencies remaining > > in your codebase, and is there anything we can do to help migrate? > > The dependencies that I care about run through ocaml-gettext. Gettext > is a specific method to make code internationalized and by its nature > it involves deep changes throughout our codebase, so porting away from > ocaml-gettext isn't an option any time soon. However porting > ocaml-gettext to use something else might be. > > ocaml-gettext has a tool which runs over the OCaml source code and > extracts the magic translatable strings, and it's my understanding > that this is the only reason it uses camlp4. AIUI this cannot be done > using ppx's (maybe I'm wrong about that?) but could be done using > camlp5. In fact it was me who did the original port of ocaml-gettext > from old camlp4 (ie. camlp5) to camlp4(!) > > (see libgettext-ocaml/pr_gettext.ml in the OCaml sources) > > > It's pretty exhausting trying to keep camlp4 maintained with a skeleton > > crew, and there appears to be a stubborn tail of packages which aren't > > migrating despite it having been quite a few years since the deprecation. > > I agree, however also changing working code is always a pain and > there's never a good time. > > Rich. >