• English
  • LocaleProvider

    Language for every component below it.

    书写中
    形状
    配色
    import { LocaleProvider, CharacterPicker, ActivityMark } from '@aora-bot/react';
    
    export default function Demo() {
      return (
        <div className="site-demo site-demo--column">
          <LocaleProvider locale="zh-CN">
            <ActivityMark agent={{ id: 'a' }} tool="write_file" />
            <CharacterPicker shape="hex" color="cyan" layout="row" shapes={['hex', 'pill', 'cloud']} />
          </LocaleProvider>
        </div>
      );
    }

    See internationalisation for adding languages and overriding individual strings.

    Names for identifiers

    Shape, ink and state identifiers are API — 'blob', 'blue', 'thinking' — and are never translated. Their display names are, and the locale table carries them as id-driven families: shape.*, color.*, state.*, stateDesc.* (a one-line description of each state), belt.*, hud.*, mouth.*, expression.*, plus face.* and nose.* for the line face and state.group.* for the four groups the states fall into.

    useLabel() reads those families as functions, so a component iterating SHAPE_IDS does not have to build 'shape.' + id and cast it to a key:

    mochi → Mochi, Thinking, Progresscircle → Circle, Thinking, Progressblob → Blob, Thinking, Progress
    mochi → 麻薯, 思考, 进度circle → 圆形, 思考, 进度blob → 果冻, 思考, 进度
    import { LocaleProvider, SHAPE_IDS, useLabel, type ShapeId } from '@aora-bot/react';
    
    function Names({ shapes }: { shapes: ShapeId[] }) {
      const label = useLabel();
      return (
        <div className="site-demo site-demo--column">
          {shapes.map((shape) => (
            <span className="site-demo__label" key={shape}>
              <code>{shape}</code> → {label.shape(shape)}, {label.state('thinking')}, {label.hud('progress')}
            </span>
          ))}
        </div>
      );
    }
    
    export default function Demo() {
      return (
        <div className="site-demo site-demo--column">
          <Names shapes={SHAPE_IDS.slice(0, 3)} />
          <LocaleProvider locale="zh-CN">
            <Names shapes={SHAPE_IDS.slice(0, 3)} />
          </LocaleProvider>
        </div>
      );
    }

    HUD names come from the engine's own HUD_KIND_LABELS, which already carries both languages; the locale re-exports them rather than keeping a second copy.

    Key families

    Beyond the identifier families, the table is grouped by the surface that reads it: picker.*, editor.*, activity.*, template.*, avatar.*, occupancy.*, restricted.*, boot.* and loading.label, cast.*, walkthrough.*, sprite.*. LocaleKey is a closed union over all of them, so an override with a misspelt key is a type error rather than a silent no-op.

    API

    PropTypeDefaultDescription
    children*string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | null——
    locale"en-US" | "zh-CN"'en-US'Language for every component below this point.
    overridesPartial<Locale>—Override individual strings without replacing the whole table.

    Next