lingui-macro
v1.2.2
Published
Macro for generating messages in ICU MessageFormat syntax
Downloads
82
Maintainers
Readme
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"})