alibaba / react-intl-universal

Internationalize React apps. Not only for Component but also for Vanilla JS.
1.33k stars 153 forks source link

在使用 react-intl-universal-extract 时遇到 has no default message #229

Closed xuoutput closed 10 months ago

xuoutput commented 11 months ago

在使用 react-intl-universal-extract 时遇到 has no default message,

"intl:extract": "react-intl-universal-extract --cmd extract --source-path ./src --output-path ./locales/en_US.json --verbose",

The key="Active" has no default message

import intl from 'react-intl-universal';

export const MEMBER_STATUS_ACTIVE = 'Active';
export const MEMBER_STATUS_INACTIVE = 'Inactive';

export function getMemberStatusMap(value): string {
  const res = {
    [MEMBER_STATUS_ACTIVE]: intl.get('Active'),
    [MEMBER_STATUS_INACTIVE]: intl.get('Inactive'),
  };
  return res[value];
}

是说一定给所有的都加上 .d() 么? 有点强制

关联 issue

cwtuan commented 11 months ago

react-intl-universal-extract is designed for extracting default message in source code into locale files. So the default message is required.