Skip to content

Add i18n support via JdmConfigProvider #238

@pokraev

Description

@pokraev

UI strings in @gorules/jdm-editor are hardcoded in English ('Search nodes', 'Expression...', 'Field label', etc.), making the editor hard to embed in localized products.

Proposing two optional props on the existing JdmConfigProvider (verified against v1.51.5):

import deDE from 'antd/locale/de_DE';

const messages = {
  // graph-nodes.tsx → <Input placeholder='Search nodes' />
  'graph.nodes.searchPlaceholder': 'Knoten suchen',
  // expression-builder.tsx → <Input placeholder='Expression...' />
  'expression.builder.placeholder': 'Ausdruck...',
  // input-field-edit.tsx / output-field-edit.tsx → <Input placeholder='Field label' />
  'decisionTable.field.labelPlaceholder': 'Feldbezeichnung',
};

<JdmConfigProvider locale={deDE} i18n={{ messages }}>
  <DecisionGraph value={graph} onChange={setGraph} />
</JdmConfigProvider>
  • i18n.messages — flat Record<string, string>. Internal t(key, 'English fallback') helper means missing keys (or no provider at all) render today's English. Fully backward-compatible.
  • locale — forwarded to the antd ConfigProvider already used internally, so antd's own strings (DatePicker, Empty, etc.) localize too.

Why minimal: no new dependencies, no structural refactor — just a small I18nContext + useI18n() hook, and each string becomes t('key', 'English') one site at a time. Strings can be migrated incrementally per component (Decision Graph → Decision Table → Expression nodes → CodeEditor → simulator), each step independently shippable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions