Files
payloadcms/packages/translations
Alessio Gravili 1c89291fac feat(richtext-lexical): utility render lexical field on-demand (#13657)
## Why this exists

Lexical in Payload is a React Server Component (RSC). Historically that
created three headaches:

1. You couldn’t render the editor directly from the client.
2. Features like blocks, tables, upload and link drawers require the
server to know the shape of nested sub‑fields at render time. If you
tried to render on demand, the server didn’t know those schemas.
3. The rich text field is designed to live inside a Form. For simple use
cases, setting up a full form just to manage editor state was
cumbersome.

## What’s new

We now ship a client component, `<RenderLexical />`, that renders a
Lexical editor **on demand** while still covering the full feature set.
On mount, it calls a server action to render the editor on the server
using the new `render-field` server action. That server render gives
Lexical everything it needs (including nested field schemas) and returns
a ready‑to‑hydrate editor.

## Example - Rendering in custom component within existing Form

```tsx
'use client'

import type { JSONFieldClientComponent } from 'payload'

import { buildEditorState, RenderLexical } from '@payloadcms/richtext-lexical/client'

import { lexicalFullyFeaturedSlug } from '../../slugs.js'

export const Component: JSONFieldClientComponent = (args) => {
  return (
    <div>
      Fully-Featured Component:
      <RenderLexical
        field={{ name: 'json' }}
        initialValue={buildEditorState({ text: 'defaultValue' })}
        schemaPath={`collection.${lexicalFullyFeaturedSlug}.richText`}
      />
    </div>
  )
}
```

## Example - Rendering outside of Form, manually managing richText
values

```ts
'use client'

import type { DefaultTypedEditorState } from '@payloadcms/richtext-lexical'
import type { JSONFieldClientComponent } from 'payload'

import { buildEditorState, RenderLexical } from '@payloadcms/richtext-lexical/client'
import React, { useState } from 'react'

import { lexicalFullyFeaturedSlug } from '../../slugs.js'

export const Component: JSONFieldClientComponent = (args) => {
  const [value, setValue] = useState<DefaultTypedEditorState | undefined>(() =>
    buildEditorState({ text: 'state default' }),
  )

  const handleReset = React.useCallback(() => {
    setValue(buildEditorState({ text: 'state default' }))
  }, [])

  return (
    <div>
      Default Component:
      <RenderLexical
        field={{ name: 'json' }}
        initialValue={buildEditorState({ text: 'defaultValue' })}
        schemaPath={`collection.${lexicalFullyFeaturedSlug}.richText`}
        setValue={setValue as any}
        value={value}
      />
      <button onClick={handleReset} style={{ marginTop: 8 }} type="button">
        Reset Editor State
      </button>
    </div>
  )
}
```

## How it works (under the hood)

- On first render, `<RenderLexical />` calls the server function
`render-field` (wired into @payloadcms/next), passing a schemaPath.
- The server loads the exact field config and its client schema map for
that path, renders the Lexical editor server‑side (so nested features
like blocks/tables/relationships are fully known), and returns the
component tree.
- While waiting, the client shows a small shimmer skeleton.
- Inside Forms, RenderLexical plugs into the parent form via useField;
outside Forms, you can fully control the value by passing
value/setValue.

## Type Improvements

While implementing the `buildEditorState` helper function for our test
suite, I noticed some issues with our `TypedEditorState` type:
- nodes were no longer narrowed by their node.type types
- upon fixing this issue, the type was no longer compatible with the
generated types. To address this, I had to weaken the generated type a
bit.

In order to ensure the type will keep functioning as intended from now
on, this PR also adds some type tests

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1211110462564644
2025-09-18 15:01:12 -07:00
..

Payload Translations

The home of Payloads API and Admin Panel translations.

How to contribute

Updating a translation

  1. Update the translation value
  2. Run one of the following:
    yarn build
    // or
    npm build
    // or
    pnpm build
    

Adding a new translation

  1. Add the new translation key/value pair for all languages located in the <payload-repo-root>/packages/translations/src/languages folder
  2. Run one of the following:
    yarn build
    // or
    npm build
    // or
    pnpm build
    

Adding a new language

  1. Create a new TS file in the <payload-repo-root>/packages/translations/src/languages folder, use the language code as the file name (e.g. <payload-repo-root>/packages/translations/src/languages/en.ts for English)
  2. Copy all translations from an existing language file and update all of the translations to match your new language. Make sure the translation object containing all the translations is type DefaultTranslationsObject.
  3. Run one of the following:
    yarn build
    // or
    npm build
    // or
    pnpm build
    
  4. Import and export your new language file from within <payload-repo-root>/packages/translations/src/exports/all.ts
  5. Re-export the file from within <payload-repo-root>/packages/payload/src/exports/i18n/[your-new-language].ts

Here is a full list of language keys. Note that these are not all implemented, but if you would like to contribute and add a new language, you can use this list as a reference:

Language Code Language Name
af Afrikaans
am Amharic
ar-sa Arabic (Saudi Arabia)
as Assamese
az-Latn Azerbaijani (Latin)
be Belarusian
bg Bulgarian
bn-BD Bangla (Bangladesh)
bn-IN Bangla (India)
bs Bosnian (Latin)
ca Catalan Spanish
ca-ES-valencia Valencian
cs Czech
cy Welsh
da Danish
de German (Germany)
el Greek
en-GB English (United Kingdom)
en-US English (United States)
es Spanish (Spain)
es-ES Spanish (Spain)
es-US Spanish (United States)
es-MX Spanish (Mexico)
et Estonian
eu Basque
fa Persian
fi Finnish
fil-Latn Filipino
fr French (France)
fr-FR French (France)
fr-CA French (Canada)
ga Irish
gd-Latn Scottish Gaelic
gl Galician
gu Gujarati
ha-Latn Hausa (Latin)
he Hebrew
hi Hindi
hr Croatian
hu Hungarian
hy Armenian
id Indonesian
ig-Latn Igbo
is Icelandic
it Italian (Italy)
it-it Italian (Italy)
ja Japanese
ka Georgian
kk Kazakh
km Khmer
kn Kannada
ko Korean
kok Konkani
ku-Arab Central Kurdish
ky-Cyrl Kyrgyz
lb Luxembourgish
lt Lithuanian
lv Latvian
mi-Latn Maori
mk Macedonian
ml Malayalam
mn-Cyrl Mongolian (Cyrillic)
mr Marathi
ms Malay (Malaysia)
mt Maltese
nb Norwegian (Bokmål)
ne Nepali (Nepal)
nl Dutch (Netherlands)
nl-BE Dutch (Netherlands)
nn Norwegian (Nynorsk)
nso Sesotho sa Leboa
or Odia
pa Punjabi (Gurmukhi)
pa-Arab Punjabi (Arabic)
pl Polish
prs-Arab Dari
pt-BR Portuguese (Brazil)
pt-PT Portuguese (Portugal)
qut-Latn Kiche
quz Quechua (Peru)
ro Romanian (Romania)
ru Russian
rw Kinyarwanda
sd-Arab Sindhi (Arabic)
si Sinhala
sk Slovak
sl Slovenian
sq Albanian
sr-Cyrl-BA Serbian (Cyrillic, Bosnia and Herzegovina)
sr-Cyrl-RS Serbian (Cyrillic, Serbia)
sr-Latn-RS Serbian (Latin, Serbia)
sv Swedish (Sweden)
sw Kiswahili
ta Tamil
te Telugu
tg-Cyrl Tajik (Cyrillic)
th Thai
ti Tigrinya
tk-Latn Turkmen (Latin)
tn Setswana
tr Turkish
tt-Cyrl Tatar (Cyrillic)
ug-Arab Uyghur
uk Ukrainian
ur Urdu
uz-Latn Uzbek (Latin)
vi Vietnamese
wo Wolof
xh isiXhosa
yo-Latn Yoruba
zh-Hans Chinese (Simplified)
zh-Hant Chinese (Traditional)
zu isiZulu