首页 > 解决方案 > 无法生成翻译文件 FormatJS

问题描述

我无法生成翻译文件。有人可以帮忙吗?

const NTTracker = () => {
  const intl = useIntl()

  return (
    <>
      <FormattedMessage
          description="A message"
          defaultMessage="Index page, nothing here"
      />

当我跑的时候

npm run extract -- 'src/**/*.js*' --out-file lang/en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'

输出lang/en.json只有{}.

由于我一直在关注文档,因此我无法完全弄清楚问题所在。我的文件结构如下:

|-- src
    |-- nttracker
        |-- dom.js (the file with <FormattedMessage/>
|-- lang
    |-- en.json
|-- package.json

提前致谢。

标签: javascriptreactjsformatjs

解决方案


推荐阅读