Skip to content

I18n#6

Open
Ninjapouet wants to merge 6 commits intoOCamlPro:masterfrom
Ninjapouet:i18n
Open

I18n#6
Ninjapouet wants to merge 6 commits intoOCamlPro:masterfrom
Ninjapouet:i18n

Conversation

@Ninjapouet
Copy link
Copy Markdown
Collaborator

An internationalization proposal for OCaml.

Julien Blond added 6 commits December 19, 2025 10:46
This RFC proposes a lightweight, format-agnostic codec library for
encoding/decoding OCaml types. Key features:

- Minimal dependencies (fmt only for core)
- First-class codec values with combinators
- Driver-based architecture for custom formats
- PPX deriver for automatic codec generation
- Streaming via composition (no special API)

Includes state of the art analysis comparing ppx_deriving_yojson,
ppx_protocol_conv, data-encoding, Repr, and ppx_sexp_conv.
The existing deriver approach allows composition ([@@deriving yojson, yaml]),
so code duplication is not a valid criticism.
- Clarify users_codec example with type annotation
- Use stdlib Out_channel instead of undefined write_file
- Note that decode currently raises, improvement planned
- Expand ppx_codec package structure to be more realistic
- Note that binary driver example is simplified
- Use "a few dozen lines" instead of precise estimate
- Remove incorrect "not valid OCaml" comment on rank-2 type
Document an alternative approach using runtime type representations
(like typerep or Repr) instead of direct code generation. Analyze
trade-offs and options for using existing libraries vs defining our own.
Add ATD (Adaptable Type Definitions) as an IDL-based alternative in the
state of the art section. Position codec and ATD as complementary: ATD
for cross-language API contracts, codec for OCaml-native serialization
with full type system expressivity.
Propose a comprehensive i18n solution targeting parity with Java/JavaScript,
built on Unicode MessageFormat 2.0 (MF2) and ICU4X. Three components:

- ocaml-icu4x: bindings to ICU4X for locale-aware formatting (numbers,
  dates, currencies), collation, plural rules, and text segmentation
- ppx_i18n: compile-time type-safe message translation with MF2 syntax,
  contract-based verification, and asymmetric localization support
- ocaml-i18n-tool: CLI for translation workflow (extraction, validation,
  format conversion, coverage statistics)

Includes state of the art comparison across 7 mainstream languages,
4-phase implementation plan, and architectural decision records.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant