ResilientLang docsDeveloper documentation (draft, product name is a placeholder)

Strings and keys

The key#

key = first 16 hex characters of SHA-256( UTF-8( normalize(sourceText) ) )

normalize is Unicode NFC, then every run of Unicode White_Space characters becomes one space, then trim spaces at both ends. The White_Space set is explicit (U+0009-000D, U+0020, U+0085, U+00A0, U+1680, U+2000-200A, U+2028, U+2029, U+202F, U+205F, U+3000); regular-expression \s is not used because engines disagree about it. Segments longer than 20,000 characters are not keyed.

Worked examples (from the shared test vectors, which the C#, TypeScript and PHP implementations all pass):

Source textKey
Add to cart0e9408353c729c32
Add + newline + tab + to cart (extra whitespace)0e9408353c729c32 (same key)
Add to <1>cart</1> now22f08fe66fcada83

You can check one yourself:

printf 'Add to cart' | sha256sum | cut -c1-16

Inline markup#

A block such as Add to <b>cart</b> now becomes one string with numbered tags: Add to <1>cart</1> now. Void and opaque elements become <2/>. Translators may reorder tags but must keep every pair and number. The loader rebuilds the DOM by re-applying the original elements, with their attributes, in order. A translation that drops or duplicates a tag is rejected and the source text stays.

Variables#

Placeholders such as {0}, {name}, {{count}} and %s are replaced by protected tokens ⟦p1⟧ and restored after translation. Each token must appear exactly once in the translation.

Never translated#

script, style, noscript, template, and the text of code, pre, kbd, samp, textarea, svg, math, iframe, object, embed, canvas. Anything with translate="no" or the class notranslate, together with its descendants. Segments with no letters (numbers, symbols) are not extracted.

Attributes#

alt, title, placeholder, aria-label, the value of submit, button and reset inputs, and the content of selected meta tags (description and Open Graph titles) are extracted as separate attr strings.

The normative text is EXTRACTION_SPEC.md with 44 extraction and 11 apply test vectors in the repository.