Registry / serialization / messageformat-convert

messageformat-convert

JSON →
library0.4.0jsnpmunverified

Convert input formats (e.g., Rails i18n YAML) into messageformat-compatible JSON. Version 0.4.0 is the latest stable release. The package is part of the messageformat ecosystem but has seen no recent updates or releases. It supports Node.js >=6.0 and converts Rails-style nested key-value pairs into flat message format strings. Note that this package does not handle MessageFormat 2.0 (MF2) syntax, only the legacy ICU MessageFormat format used by messageformat 2.x and 3.x.

npm install messageformat-convert
INSTALL
IMPORT
SIG · MESSAGEFORMAT-CONV
M
messageformat-convert
serializationjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convert
import { convert } from 'messageformat-convert'
const convert = require('messageformat-convert')
The package is ESM-only; CommonJS require() will fail.
convert
import convert from 'messageformat-convert'
import { convert } from 'messageformat-convert'
Default export is a single convert function; named import { convert } does not exist.
convert
import convert from 'messageformat-convert'
const { convert } = require('messageformat-convert')
The package does not export a named convert via CommonJS; it's a default export.

Shows how to convert Rails i18n YAML to messageformat-compatible JSON using import syntax.

import convert from 'messageformat-convert'; import yaml from 'js-yaml'; import fs from 'fs'; const railsI18n = yaml.load(fs.readFileSync('config/locales/en.yml', 'utf8')); // railsI18n might be: { en: { greeting: 'Hello', farewell: 'Goodbye' } } const mfData = convert(railsI18n.en); console.log(mfData); // Output: { greeting: 'Hello', farewell: 'Goodbye' }
Debug
Known issues
gotchaPackage is outdated and may not support modern node versions or MF2 syntax. Use messageformat 4.x with its own converters for MF2.
fix
Consider using messageformat's built-in adapters or the @messageformat/icu-messageformat-1 package for legacy ICU support.
affects: >=0.0.0
deprecatedThe convert function expects a flat object; nested structures are not handled correctly. It does not perform deep conversion.
fix
Flatten your structure manually before passing, or use a library like flat.
affects: >=0.0.0
gotchaNo TypeScript typings included. Using with TypeScript may require manual type definitions.
fix
Install @types/messageformat-convert or declare module 'messageformat-convert'.
affects: >=0.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token 'export'
Package is ESM-only but project uses CommonJS (require).
fix
Use import instead: import convert from 'messageformat-convert'; or set type: 'module' in package.json.
TypeError: convert is not a function
Wrong import style: using named import { convert } instead of default import.
fix
Use: import convert from 'messageformat-convert';
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
messageformat-convert — npm install messageformat-convert · libregistry