ERC-1444 A standard for converting codes into multilingual text (Localized Messaging with Signal-to-Text)

Stagnant · Other · created 2018-09-23

Smart contracts return numeric codes or state values. This provides an on-chain translation system that converts these into human-readable text in the language set by the user.

Why it is needed

Smart contracts represent state or errors as numeric codes, enums, booleans, or machine-friendly signals like ERC-1066. Showing these codes directly to users makes them meaningless, which hurts the user experience, and information that comes back as a code, like a revert message, is hard even for developers to interpret. Conversely, hardcoding strings to return usually means writing them in a single language, English, so the many non-English-speaking users worldwide who interact with Ethereum have no way to understand the results. When each project builds its own translations separately, they cannot be reused or shared elsewhere, and if a translation for a particular code does not yet exist, only an empty string is returned, conveying no information at all.

What to implement

In depth

Two kinds of contract structure

Localization is a simple contract holding only a mapping from codes to text, while LocalizationPreferences is a proxy that selects the Localization preferred by tx.origin on their behalf. A Requestor only needs to call the single LocalizationPreferences contract, and the actual text lookup is delegated to the Localization the user has registered.

Fallback behavior rules

The spec requires (MUST) that a default Localization with all keys filled in must exist. If textFor on a user-specified Localization returns an empty string ("") for a given code, LocalizationPreferences must re-delegate to the default Localization, and in this case the first return value of textFor (_wasFound) becomes false, signaling that the translation was substituted.

Why bytes32 keys

bytes32 is efficient because it is the EVM's native word size, and it can hold more than 1.1579x10^77 values, enough to represent almost any signal, enum, or state. If a key is longer than bytes32 it is mapped via a hash, and smaller types like ERC-1066's bytes1 can be embedded directly within a bytes32.

String encoding

All strings must (MUST) be encoded in UTF-8, since it includes ASCII as-is while still being able to represent most natural languages, special characters, and even emoji.

printf-style templates and parameter ordering

Template strings must (MUST) follow ANSI C printf conventions. If there are two or more arguments, it is recommended (SHOULD) to use the POSIX parameter field extension (notation like %1$s). This lets translators freely reorder the arguments' appearance since word order differs by language, and a translated text need not use all of the given arguments.

Interpolation is recommended to happen off-chain

The spec explains that it is preferable to return or emit the template string itself as an event and perform the actual string interpolation off-chain. It gives an example event containing fields like templateCode, atomCode, and atomicNumber, showing how the receiving side looks up each code via textFor and then combines them with printf.

Deliberately unspecified aspects

The spec deliberately does not define whether the default Localization is public or private, who can set text (deployer, onlyOwner, anyone, etc.), or when it can be set (only in the constructor, at any time, only for empty slots, etc.). These are left open for implementations to decide per use case.

A Proposal Still Stalled

This ERC is in Stagnant status, meaning it is a proposal that is no longer being actively discussed or moving through the adoption process. It has not been finalized as a standard, so its current status should be checked before actual use.

Original ERC · ← ERCs