OCAML-GETTEXT(1)
β¨ ocaml-gettext β¨
okay so bestie, you just opened the OCAML-GETTEXT(1) manual page and I am SO glad you're here π this is the whole thing, top to bottom, nothing skipped, fr fr. grab a strawberry π and let's go.
πΈ NAME πΈ
ocaml-gettext β the program that manages PO and MO files for your OCaml source files. that's it, that's the vibe. π
π¦ SYNOPSIS π¦
ocaml-gettext --action verb options* [file...]
π DESCRIPTION π
this page is the quick rundown of the ocaml-gettext command β the little overview, the appetiser, the teaser π
now the actions, because this is where the main character energy lives:
--action extractβ the files you hand over get treated like OCaml source files, andocaml-gettexttries to pull the translatable strings out of them. what you get back is a POT file. β¨ special-case alert β¨: if a file namedPOTFILESis in the list of files you provided, then every single line of it counts as a file to be searched. iconic behaviour honestly.--action compileβ the files you give it are treated as PO files, and they get compiled into binary MO files.--action installβ the files you give it are treated as MO files, and they get installed into their respective directories, taking language, textdomain and category into account.--action uninstallβ the symmetric twin of install π«Ά it uninstalls the files you provided for the language, textdomain and category in question.--action mergeβ merges a POT file with the PO file you provided.
and now the options, one by one, no skipping, we stay thorough:
--extract-command cmdβ the command used to extract translatable strings from an OCaml source file. this command has to output the same marshalled structure asocaml-xgettext. best practice? use the same build version ofocaml-gettext. no cap.--extract-default-option optionsβ the default options used when extracting translatable strings. these are camlp4 options and they get passed toocaml-xgettextwhen it's processing files that don't already have their own specific camlp4 options.--extract-filename-option filename optionsβ specific per-filename camlp4 options. used when extracting strings from the specified filename. it overrides the default camlp4 options. π--extract-pot filenameβ the POT file to write when extracting translatable strings.--compile-output filenameβ the MO file to write when compiling a PO file. if you don't provide it, the output is just the name of the PO file with a.moextension.--install-language languageβ the language to use when installing a MO file.--install-category categoryβ the category to use when installing a MO file.--install-textdomain textdomainβ the textdomain to use when installing a MO file.--install-destdir dirnameβ the base directory to use when installing a MO file.--uninstall-language languageβ the language to use when uninstalling a MO file.--uninstall-category categoryβ the category to use when uninstalling a MO file.--uninstall-textdomain textdomainβ the textdomain to use when uninstalling a MO file.--uninstall-orgdir dirnameβ the base directory used when uninstalling a MO file.--merge-pot filenameβ the POT file to use as a master for merging a PO file.--merge-backup-extension extensionβ the backup extension to use when moving PO files that have been merged.--versionβ returns version info aboutocaml-gettext.--short-versionβ returns only the version ofocaml-gettext. the return is made to be easily parseable by a configure script. the output of this command will always be the shortest version string, made up of numeric characters (0-9) and".". you should compare version strings knowing that a version A is greater than a version B if there is a number between two"."of A that is greater than the corresponding number of B, starting at the right of the string. for example:0.14is greater than0.13.1. π§-help,--helpβ displays the help about theocaml-gettextcommand.
π OCAML-GETTEXT OPTIONS π
this section briefly describes the common options provided by programs that use the ocaml-gettext library. okay bestie, here we go:
--gettext-failsafe ignoreβ defines the behaviour ofocaml-gettextfor any error that could be encountered while processing string translation.ignoreis the default behaviour. the string returned is the original string, untranslated. this behaviour is consistent and lets you have usable output even if it isn't perfect. π--gettext-failsafe inform-stderrβ same behaviour asignore, except that a message is printed on stderr.--gettext-failsafe raise-exceptionβ stops the program by raising an exception when an error is encountered. π¨ dramatic, on purpose.--gettext-disableβ disables any translation made byocaml-gettext. all translations return the original string, untranslated.--gettext-domain-dir textdomain dirβ defines a dir to search for a specific domain. this could be useful if MO files are stored in a non standard directory.--gettext-dir dirβ adds a directory to search for MO files.--gettext-language languageβ sets the language to use in the ocaml-gettext library. the language should be POSIX compliant. it should follow this convention:lang[_territory][.charset][@modifier]. thelangandterritoryshould be two letters ISO code. the charset should be a valid ISO character set (at least recognised by the underlying charset recoding routine). for example, valid languages are:fr_FR.ISO-8859-1@euro,de_DE.UTF-8.--gettext-codeset codesetβ sets the codeset for output.
heads up bestie π you should be aware that these command line options apply only for strings after the initialisation of the library. this means that if the options initially guessed byocaml-gettextdon't match the command line you provided, there will probably be some untranslated string, because those strings are translated before options get parsed. this is particularly true for the usage message itself (--help): even if the strings are translated, they are translated before setting the correct option. yeah. it's giving chicken-and-egg.
some options (--gettext-codeset for example) are overridden internally for particular use. you should always translate strings to UTF-8 in a graphical user interface (because GTK2 requires it). π
π NOTES π
the options --uninstall-language, --uninstall-textdomain, --install-language and --install-textdomain could be guessed from the filename you provide. but listen β you must be aware that these options can conflict with the fact that you provide several files to install.
for example, if you provide a textdomain, you should either install several MO files whose filenames only reflect the language, or only one MO file if you also provide a language.
so like, you can totally run:
ocaml-gettext --install-textdomain mytextdomain fr.po de.po
without a problem β¨ but you cannot run:
ocaml-gettext --install-textdomain mytextdomain --install-language fr fr.po de.po
this restriction exists because you should not over-specify file installation. periodt.
the rules for guessing the language/textdomain are: language[.textdomain].mo. so for a fully automated install, without giving any hints through command line options, you should name your file fr.mytextdomain.mo or de.mytextdomain.mo. slay. π
π SEE ALSO π
ocaml-xgettext(1), ocaml-gettext(5).
π AUTHORS π
Sylvain Le Gall.
and that's a wrap, bestie π¦ this was the OCAML-GETTEXT(1) page, dated 2008-04-29, and you ate the whole thing. go forth and translate. ππΈβ¨
π¦ where this page comes from
- alpine 3.24: ocaml-gettext-doc 0.4.2-r6 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- centos-stream 10: ocaml-gettext-devel 0.4.2-23.el10 Β· LGPL-2.1-or-later with OCaml-LGPL-linking-exception
- centos-stream 9: ocaml-gettext-devel 0.4.2-6.el9 Β· LGPLv2+ with exceptions
- debian bookworm: libgettext-ocaml-dev 0.4.2-1+b5 Β· LGPL-2.1-or-later
- debian trixie: libgettext-ocaml-dev 0.5.0+really0.4.2-1+b1 Β· LGPL-2.1-or-later
- fedora 43: ocaml-gettext-devel 0.5.0-6.fc43 Β· LGPL-2.1-or-later with OCaml-LGPL-linking-exception
- fedora 44: ocaml-gettext-devel 0.5.0-8.fc44 Β· LGPL-2.1-or-later with OCaml-LGPL-linking-exception
- nixos 26.05: ocaml5.4.1-gettext 0.5.0
- nixpkgs unstable: ocaml5.5.1-gettext 0.5.0
- opensuse-leap 16.0: ocaml-gettext 0.4.2-160000.3.2 Β· SUSE-LGPL-2.0-with-linking-exception
- opensuse-leap 16.0: ocaml-gettext 0.4.2-160000.3.2 Β· SUSE-LGPL-2.0-with-linking-exception
- opensuse-leap 16.0: ocaml-gettext 0.4.2-160000.3.2 Β· SUSE-LGPL-2.0-with-linking-exception
- opensuse-leap 16.0: ocaml-gettext 0.4.2-160000.3.2 Β· SUSE-LGPL-2.0-with-linking-exception
- ubuntu jammy: libgettext-ocaml-dev 0.4.2-1build3 Β· LGPL-2.1-or-later
- ubuntu noble: libgettext-ocaml-dev 0.4.2-3build1 Β· LGPL-2.1-or-later
- ubuntu questing: libgettext-ocaml-dev 0.5.0+really0.4.2-1build1
- ubuntu resolute: libgettext-ocaml-dev 0.5.0++git5-g6591d7a-1build1 Β· LGPL-2.1-or-later
- ubuntu stonking: libgettext-ocaml-dev 0.5.0++git5-g6591d7a-1build3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms