@c This file is part of the GNU gettext manual.
@c Copyright (C) 1995-2025 Free Software Foundation, Inc.
@c See the file gettext.texi for copying conditions.

@node OCaml
@subsection OCaml
@cindex OCaml

@table @asis
@item RPMs
ocaml, ocaml-gettext-devel

@item Ubuntu packages
ocaml, opam
@*@code{opam install gettext-stub}

@item File extension
@code{ml}

@item String syntax
@code{"abc"}

@item gettext shorthand
@code{(s_ "abc")} or, for format strings, @code{(f_ "abc")}

@item gettext/ngettext functions
@code{s_}, @code{f_}, @code{sn_}, @code{fn_}, and also
@code{gettext}, @code{fgettext},
@code{dgettext}, @code{fdgettext},
@code{dcgettext}, @code{fdcgettext},
@code{ngettext}, @code{fngettext},
@code{dngettext}, @code{fdngettext},
@code{dcngettext}, @code{fdcngettext}.

@item textdomain
@code{textdomain} field in first parameter of @code{Gettext.Program}

@item bindtextdomain
@code{dir} field in first parameter of @code{Gettext.Program}

@item setlocale
---

@item Prerequisite
Declare the libraries @code{gettext.base} and @code{gettext-stub}
in the @samp{dune} file.

@item Use or emulate GNU gettext
Use (assuming that you pass @code{GettextStub.Native}
as second parameter of @code{Gettext.Program})

@item Extractor
@code{xgettext}

@item Formatting with positions
In the source code: @code{Printf.fprintf "%d %d"}
@*In the msgid: @code{"%d %d"}
@*In the msgstr: @code{"%2$d %1$d"}
@*Note: This does not work yet; it depends on the completion of
@uref{https://github.com/gildor478/ocaml-gettext/issues/39}.

@item Portability
fully portable

@item po-mode marking
---
@end table

An example is available in the @file{examples} directory: @code{hello-ocaml}.
