Ability to extract strings from intl-messageformat strings
swac opened this issue · 2 comments
Which package?
intl-messageformat
Is your feature request related to a problem? Please describe.
I'd like to use intl-messageformat
for a Node.js project. I've seen that there is a CLI for extracting strings from code into JSON files.
From the docs, I don't see an obvious way to achieve this. I have a string like this in my code:
const msg = new IntlMessageFormat('This is my string.', 'en-US').format();
I'd like to run the CLI to extract this into JSON in some way. I assume I would need to be able to specify an id
and description
for the string, but I'm not seeing where those would be specified.
Describe the solution you'd like
Something similar to react-intl
's formatMessage
or defineMessage
functions would be great. If I could initialize a formatter with a locale, the way react-intl
has IntlProvider
, and then call formatMessage
with an id
, description
, and defaultValue
, that could work.
Describe alternatives you've considered
I'm new to this library and i18n in general, so I'm not sure what the alternatives would be.
@swac react-intl does support non-React env so maybe you can use that: https://github.com/formatjs/react-intl/blob/master/docs/API.md#createintl