> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/database/schema/field-types/translatable.md).

# Translatable text

A text field that keeps one value per language, stored as a language → text object.

A **translatable** text field keeps one string per language: `{ "en": "Hello", "lt": "Labas" }`. It is a [Text](/codemash/cloud/database/schema/field-types/text.md) field with `meta.translateOptions`; every translation follows the field's length and pattern rules.

**Builder:** Form fields panel → **Text → Translatable** · widget `text` / `textarea` / `html` · data type `string.schema.v1`

## Data schema

```json
{
  "name": {
    "type": "string",
    "maxLength": 100,
    "meta": {
      "translateOptions": { "translatable": true, "atLeastOneTranslation": true }
    }
  }
}
```

| Keyword                                       | Required          | What it does                                                                           | Example    |
| --------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------- | ---------- |
| `type`                                        | yes               | Always `"string"`.                                                                     | `"string"` |
| `meta.translateOptions.translatable`          | yes for this type | `true` = the record stores a language → text object. `{}` or `false` = a plain string. | `true`     |
| `meta.translateOptions.atLeastOneTranslation` | no                | `true` = a translation in at least one language is expected.                           | `true`     |
| `minLength`, `maxLength`, `pattern`           | no                | Checked on **each** translation.                                                       | `100`      |

### What the server refuses

Every write — insert, update, replace; from Cloud, the API, an SDK, the CLI or an AI agent — is checked against the published schema. A broken value is answered with one error per field: the code, and `Field '<name>' is invalid: <reason>`. Nothing is written.

| Case                                       | Code                             | The reason it gives                                      |
| ------------------------------------------ | -------------------------------- | -------------------------------------------------------- |
| a required field is missing or `null`      | `CM-ERRORS-DATABASE-030`         | `a value is required`                                    |
| the value is not an object of translations | `CM-ERRORS-DATABASE-049`         | `must be an object of translations, e.g. {"en": "text"}` |
| a translation that is not a string         | `CM-ERRORS-DATABASE-049`         | `the 'en' translation must be a string`                  |
| an empty language code                     | `CM-ERRORS-DATABASE-049`         | `a language code cannot be empty`                        |
| a translation breaks the text rules        | `CM-ERRORS-DATABASE-040` / `041` | `must be at most 100 characters (lt)`                    |

A keyword that is not in the table above is refused when the schema is **saved**, not when a record is written: `CM-ERRORS-SCHEMA-010` — `Data schema violates meta-schema: Property 'sort' has not been defined and the schema does not allow additional properties. Path 'properties.name.sort' (field 'properties.name' checked as string.schema.v1).`

## UI schema

The widget is the same as for the plain field (`text`, `textarea` or `html`); the form shows one input per project language. The project's languages are set in [Project → Settings → Languages](/codemash/cloud/project/settings/languages.md).

```json
{
  "colSpan": 6,
  "element": {
    "fieldId": "name",
    "meta": { "widget": "text", "label": "Name" }
  }
}
```

Every cell also takes the common layout options: `label`, `placeholder`, `help` (the text under the input), `required`, `readonly` and `hidden`. Keys outside this list — `watermark`, `hint`, `permissions` — are refused when the schema is saved (`CM-ERRORS-SCHEMA-012`), see [Schema authoring guide](/codemash/cloud/database/schema.md#one-contract-no-second-dialect).

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-ebf915cf71f4945a3c0d5bf9ef1529c892da44f4%2Ffield-types-text-1.png?alt=media" alt="The Text tab of the all-types record form; String meta and String meta translateOptions are the translatable cells, rendered with the text widget"><figcaption><p>Translatable cells (String meta, String meta translateOptions) on the Text tab use the text widget.</p></figcaption></figure>

## Records

A record the schema accepts:

```json
{ "name": { "en": "Hello", "lt": "Labas" } }
```

A record it refuses:

```json
{ "name": "Hello" }
```

The answer: `CM-ERRORS-DATABASE-049` — `Field 'name' is invalid: must be an object of translations, e.g. {"en": "text"}`. In Cloud the same sentence is shown under the field before the form is sent; the server repeats the check on every API write.

## Good to know

* Language codes are not checked against the project's language list on write; any non-empty code is stored.
* A `null` translation is skipped, not refused — a language can be left empty.
* The AI schema bundle tool sets this flag on free-text fields when you pass `translatable: true` — see [What agents can do](/codemash/ai/developers/what-agents-can-do.md).

## Do it from code

```ts
await norbix.api.database.insertOne({
  collectionName: 'products',
  document: JSON.stringify({ name: { en: 'Hello', lt: 'Labas' } }),
});
```

```sh
norbix api database one insert --collectionName products --document '{"name":{"en":"Hello","lt":"Labas"}}'
```

The client setup is on the [Database page](/codemash/cloud/database.md#use-it-from-code). API: [Insert One](/codemash/api-reference/database/collections/insert-one.md) · [Save Database Schema](/codemash/api-reference/database/schemas/save-database-schema.md)

## Related

[Text](/codemash/cloud/database/schema/field-types/text.md) · [Languages](/codemash/cloud/project/settings/languages.md) · [Field type reference](/codemash/cloud/database/schema/field-types.md) · [Schema authoring guide](/codemash/cloud/database/schema.md) · [Create a schema](/codemash/cloud/database/collections/create-schema.md)
