0

我试图在 antd 中翻译标题,modal.confirm()但总是收到错误消息useLingui hook was used without I18nProvider。在其他页面中,翻译工作正常。

这是我的代码:

async function onLogout() {
    Modal.confirm({
        title: <Trans>Confirm Logout</Trans>,
        icon: <LogoutOutlined />,
        content: <Trans>Are you sure you want to logout?</Trans>,
        async onOk() {
            const logout = await dispatch(logoutUser())
            if (logout === "Success") {
                history.push("/login")
            }
        },
    })
}
4

1 回答 1

1

我为 ant d modal.method 上下文包装了单独的 I18nProvider

   const comfirmLogoutMessage = (
    <I18nProvider i18n={i18n}>
      <Trans>Confirm Logout</Trans>
    </I18nProvider>
)
于 2020-12-20T14:07:48.403 回答