From 1065e5e61639872ed06da73963efd4961ea4a6ec Mon Sep 17 00:00:00 2001 From: Junyi Date: Wed, 2 Nov 2022 00:29:50 +0800 Subject: [PATCH] fix(sample): fix shop-i18n client (#1005) --- packages/samples/shop-i18n/README.md | 6 +- .../samples/shop-i18n/src/client/index.tsx | 65 +++++++++++++++++-- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/packages/samples/shop-i18n/README.md b/packages/samples/shop-i18n/README.md index 9a6d6b7d5..a087400d4 100644 --- a/packages/samples/shop-i18n/README.md +++ b/packages/samples/shop-i18n/README.md @@ -1,15 +1,15 @@ -# Modeling for simple shop scenario +# I18n for simple shop scenario ## Register ```ts -yarn pm add sample-shop-modeling +yarn pm add sample-shop-i18n ``` ## Activate ```bash -yarn pm enable sample-shop-modeling +yarn pm enable sample-shop-i18n ``` ## Launch the app diff --git a/packages/samples/shop-i18n/src/client/index.tsx b/packages/samples/shop-i18n/src/client/index.tsx index e7f1fdaca..ca835122b 100644 --- a/packages/samples/shop-i18n/src/client/index.tsx +++ b/packages/samples/shop-i18n/src/client/index.tsx @@ -1,10 +1,15 @@ - -import React from 'react'; -import { Select } from 'antd'; -import { i18n } from '@nocobase/client'; +import React, { useContext } from 'react'; +import { useHistory } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; +import { Select } from 'antd'; +import { ShopOutlined } from '@ant-design/icons'; +import { i18n, PluginManager, PluginManagerContext, RouteSwitchContext, SettingsCenterProvider } from '@nocobase/client'; -i18n.addResources('zh-CN', '@nocobase/plugin-sample-shop-i18n', { +const ns = '@nocobase/plugin-sample-shop-i18n'; + +i18n.addResources('zh-CN', ns, { + Shop: '店铺', + I18n: '国际化', Pending: '已下单', Paid: '已支付', Delivered: '已发货', @@ -20,7 +25,7 @@ const ORDER_STATUS_LIST = [ ] function OrderStatusSelect() { - const { t } = useTranslation('@nocobase/plugin-sample-shop-i18n'); + const { t } = useTranslation(ns); return (