JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q66769F
  • License MIT

Macro for generating messages in ICU MessageFormat syntax

Package Exports

  • lingui-macro
  • lingui-macro/node

Readme

License Version Downloads Babel Macro

lingui-macro

Babel Macros which transforms tagged template literals and JSX components to ICU MessageFormat.

lingui-macro is modified version of @lingui/macro in which defineMessage macro returns string instead of MessageDescriptor. (Migration purpose)

Installation

npm install --save-dev @lingui/macro@npm:lingui-macro
# yarn add --dev @lingui/macro@npm:lingui-macro

Usage

See the reference documentation.

import { setupI18n } from "@lingui/core"
import { defineMessage } from "@lingui/macro"

const message = defineMessage`Hello, my name is {name}`;

/**
 * line above is transformed using babel-plugin-macros to string instead of MessageDescriptor
 * 
 * @lingui/macro:
 * const message = {id:"msgId", message: "Hello, my name is {name}"};
 * 
 * lingui-macro:
 * const message = `Hello, my name is {name}`;
*/

const i18n = setupI18n();

const translatedMessage = i18n._(message, {name: "Steve"})

License

MIT