PPX rewriter
The ocsigen-i18n-rewriter PPX extension transforms [%i18n ...] expressions into calls to the generated translation functions.
Setup
Add the PPX to your dune file:
(preprocess (pps ocsigen-i18n -- --default-module MyI18n))
where MyI18n is the name of the module generated by ocsigen-i18n-generator (the basename of the output file, capitalized).
Without dune, use:
-ppx 'ocsigen-i18n-rewriter --default-module MyI18n'
Expressions
The PPX supports the following forms:
Expression | Meaning |
|---|---|
| Calls |
| Calls |
| Passes a labelled argument |
| Calls |
| Calls |
Module affixing
To avoid redundancy when using multiple i18n modules, you can auto-prefix and auto-suffix module names:
(preprocess (pps ocsigen-i18n -- --default-module MyI18n --prefix Pr_ --suffix _i18n))
With this configuration, [%i18n Feature.foo] becomes Pr_Feature_i18n.Tr.foo ().
Important: Do not name your i18n file s.tsv, as S is reserved for the string module.