lit-translate
lit-translate copied to clipboard
CLI for extraction of messages
I'm trying to migrate a project from React to lit-html and replacing any instances of react-intl
with lit-translate
. The one thing I miss is the FormatJS CLI
It would be nice to be able to define messages in the same way, e.g.
import { defineMessages, get } from "@appnest/lit-translate";
import { html } from "lit-html";
const messages = defineMessages({
foo: {
id: 'foo',
defaultMessage: 'foo',
description: 'bar',
},
});
export default () => html`
<div>${get(messages.foo)}</div>
`;
And have a @appnest/lit-translate-cli
which could extract messages in the same way:
formatjs extract [options] [files...]
I think this approach has two advantages:
- Tools can be used to ensure localizations are in-sync and not missed
- It enforces linking localizations to the components in which they are used