{"id":25931,"library":"messageformat-convert","title":"messageformat-convert","description":"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.","status":"maintenance","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/messageformat/messageformat","tags":["javascript","messageformat","convert","rails","i18n"],"install":[{"cmd":"npm install messageformat-convert","lang":"bash","label":"npm"},{"cmd":"yarn add messageformat-convert","lang":"bash","label":"yarn"},{"cmd":"pnpm add messageformat-convert","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-only; CommonJS require() will fail.","wrong":"const convert = require('messageformat-convert')","symbol":"convert","correct":"import { convert } from 'messageformat-convert'"},{"note":"Default export is a single convert function; named import { convert } does not exist.","wrong":"import { convert } from 'messageformat-convert'","symbol":"convert","correct":"import convert from 'messageformat-convert'"},{"note":"The package does not export a named convert via CommonJS; it's a default export.","wrong":"const { convert } = require('messageformat-convert')","symbol":"convert","correct":"import convert from 'messageformat-convert'"}],"quickstart":{"code":"import convert from 'messageformat-convert';\nimport yaml from 'js-yaml';\nimport fs from 'fs';\n\nconst railsI18n = yaml.load(fs.readFileSync('config/locales/en.yml', 'utf8'));\n// railsI18n might be: { en: { greeting: 'Hello', farewell: 'Goodbye' } }\nconst mfData = convert(railsI18n.en);\nconsole.log(mfData);\n// Output: { greeting: 'Hello', farewell: 'Goodbye' }","lang":"typescript","description":"Shows how to convert Rails i18n YAML to messageformat-compatible JSON using import syntax."},"warnings":[{"fix":"Consider using messageformat's built-in adapters or the @messageformat/icu-messageformat-1 package for legacy ICU support.","message":"Package is outdated and may not support modern node versions or MF2 syntax. Use messageformat 4.x with its own converters for MF2.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Flatten your structure manually before passing, or use a library like flat.","message":"The convert function expects a flat object; nested structures are not handled correctly. It does not perform deep conversion.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Install @types/messageformat-convert or declare module 'messageformat-convert'.","message":"No TypeScript typings included. Using with TypeScript may require manual type definitions.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import instead: import convert from 'messageformat-convert'; or set type: 'module' in package.json.","cause":"Package is ESM-only but project uses CommonJS (require).","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Use: import convert from 'messageformat-convert';","cause":"Wrong import style: using named import { convert } instead of default import.","error":"TypeError: convert is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}