@palamedes/extractor
v1.25.0
Published
Native message extractor for Palamedes macro syntax
Maintainers
Readme
@palamedes/extractor
Fast message extraction for teams that want a lower-level API alongside the CLI.
@palamedes/extractor uses Palamedes' native core first to pull messages out of
JavaScript, TypeScript, JSX, and MDX codebases without sending the workflow
through a Babel-heavy path.
When To Use This Package
Use @palamedes/extractor when you want:
- direct control over extraction in your own scripts or tools
- a lower-level extractor for custom workflows
- the same extraction engine that powers the Palamedes CLI
If you just want the supported command-line workflow, use @palamedes/cli.
Installation
pnpm add -D @palamedes/extractorMinimal Example
import { extractor } from "@palamedes/extractor";
const source =
'import { t } from "@palamedes/core/macro"; function message(name) { return t`Hello ${name}` }';
const messages = [];
await extractor.extract("example.ts", source, (message) => {
messages.push(message);
});
console.log(messages);Supported Inputs
t,plural,select,selectOrdinal<Trans>,<Plural>,<Select>,<SelectOrdinal>i18n._(...)andi18n.t\...`` style runtime calls- JavaScript, TypeScript, JSX, and TSX sources
- MDX semantic units, inline rich text, expressions, images, and JSX
The extractor rejects eager t, plural, select, and selectOrdinal
macros, plus <Plural>, <Select>, and <SelectOrdinal>, when they appear
outside a function, method, or callback. <Trans> is safe at module scope
because translation occurs during component rendering. Class field initializers
do not count as function scope; use a method or getter instead.
Rich JSX children inside <Trans> are extracted with numeric component slots. For example,
<Trans><strong>A</strong> and <strong>B</strong></Trans> extracts as
<0>A</0> and <1>B</1>.
Key Exports
extractorcreateExtractor(options?)extractMessages(source, filename, mdxOptions?)ExtractedMessageInfo
Configure MDX attributes and frontmatter for direct extraction:
import { createExtractor, extractMessages } from "@palamedes/extractor";
const mdx = {
translatableAttributes: ["alt", "title", "aria-label"],
frontMatterFields: ["title", "description"],
};
const messages = extractMessages(source, "guide.mdx", mdx);
const configuredExtractor = createExtractor({ mdx });Related Packages
MDX uses the explicit palamedes-ignore directive rather than
lingui-extract-ignore.
palamedes is part of the Ferramenta family — Rust-native developer tools that keep the APIs the ecosystem already knows.
Siblings: ferroni · ferriki · ferromark · ferrolex · ferrocat · ferrovia · ferralk · ferrugo.
License
MIT OR Apache-2.0 © 2026 Sebastian Software
