andreasbm/lit-translate

CLI for extraction of messages

ryan-codingintrigue opened this issue · 0 comments

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:

  1. Tools can be used to ensure localizations are in-sync and not missed
  2. It enforces linking localizations to the components in which they are used