Skip to content

Internationalization

Ezynota has a small, namespaced i18n system built in. All UI strings flow through the I18n class with English as the fallback.

Setting a locale

ts
const editor = new Ezynota({
  target: "#app",
  locale: "de",
  i18n: {
    messages: {
      "toolbox.categories.basic": "Grundblöcke",
      "ui.deleteBlock": "Block löschen",
      "workspace.untitled": "Unbenannt",
    },
  },
});

How keys work

  • Keys are namespaced, e.g. ui.* for editor chrome, toolbox.* for the block picker, workspace.* for the workspace shell.
  • Tool and tune labels live under tool.<name>.* and tune.<name>.* — so custom tools can register their own strings.
  • Missing keys fall back to English; unknown keys render as-is (never crash).
  • {var} placeholders are substituted: "{count} words".

RTL support

Right-to-left is automatic for he, ar, fa, and ur:

ts
const editor = new Ezynota({ target: "#app", locale: "ar" });

The stylesheet uses logical properties (margin-inline, padding-inline-start) throughout, so RTL works without extra CSS.

Custom id generation

Related config: block ids can be generated by any function:

ts
const editor = new Ezynota({
  target: "#app",
  idGenerator: () => `note-${crypto.randomUUID()}`,
});

Built-in behavior: crypto.randomUUID() where available, with an ez_* prefixed fallback elsewhere.

Overriding built-in tool labels

Because tool strings are namespaced, you can rename built-ins without subclassing:

ts
i18n: {
  messages: {
    "tool.paragraph.toolbox.title": "Text",
    "tool.heading.toolbox.title": "Title",
    "tool.code.toolbox.title": "Code snippet",
  },
}

Released under the MIT License. Zero runtime dependencies.