From 8708765f43726019a658db27028676ed792d34a2 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Thu, 7 Dec 2023 21:15:40 +0800 Subject: [PATCH] fix(bi): localization (#3159) * fix(bi): localization * fix: bug * fix(map): localization * fix: antd config provider --- .../src/schema-settings/SchemaSettings.tsx | 6 +- .../client/filter/FilterItemInitializers.tsx | 78 ++++++++------- .../src/client/locale/index.ts | 4 +- .../plugin-map/src/locale/zh-CN.json | 98 +++++++++---------- 4 files changed, 97 insertions(+), 89 deletions(-) diff --git a/packages/core/client/src/schema-settings/SchemaSettings.tsx b/packages/core/client/src/schema-settings/SchemaSettings.tsx index 3985b8bb8..fbb14b49b 100644 --- a/packages/core/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettings.tsx @@ -10,6 +10,7 @@ import { Button, Cascader, CascaderProps, + ConfigProvider, Dropdown, Empty, MenuItemProps, @@ -952,6 +953,7 @@ export const SchemaSettingsModalItem: FC = (props) const { theme } = useGlobalTheme(); const ctx = useContext(BlockRequestContext); const upLevelActiveFields = useFormActiveFields(); + const { locale } = useContext(ConfigProvider.ConfigContext); if (hidden) { return null; @@ -988,7 +990,9 @@ export const SchemaSettingsModalItem: FC = (props) `} > - + + + diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterItemInitializers.tsx b/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterItemInitializers.tsx index e96ff931a..f4381f6c5 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterItemInitializers.tsx +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterItemInitializers.tsx @@ -24,6 +24,7 @@ import { Alert } from 'antd'; import { getPropsSchemaByComponent } from './utils'; import { Field, onFieldValueChange } from '@formily/core'; import { css, cx } from '@emotion/css'; +import { ConfigProvider } from 'antd'; const FieldComponentProps: React.FC = observer((props) => { const form = useForm(); @@ -78,6 +79,7 @@ export const ChartFilterFormItem = observer( export const ChartFilterCustomItemInitializer: React.FC<{ insert?: any; }> = (props) => { + const { locale } = useContext(ConfigProvider.ConfigContext); const { t: lang } = useChartsTranslation(); const t = useMemoizedFn(lang); const { scope, components } = useContext(SchemaOptionsContext); @@ -101,44 +103,46 @@ export const ChartFilterCustomItemInitializer: React.FC<{ message={t('To filter with custom fields, use "Current filter" variables in the chart configuration.')} style={{ marginBottom: 16 }} /> - + + }} + /> + ), diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/locale/index.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/client/locale/index.ts index 1ab22a13d..41d32c5da 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/locale/index.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/locale/index.ts @@ -10,9 +10,9 @@ export const NAMESPACE = 'data-visualization'; // i18n.addResources('tr-TR', NAMESPACE, trTR); export function lang(key: string) { - return i18n.t(key, { ns: NAMESPACE }); + return i18n.t(key, { ns: [NAMESPACE, 'client'] }); } export function useChartsTranslation() { - return useTranslation(NAMESPACE); + return useTranslation([NAMESPACE, 'client'], { nsMode: 'fallback' }); } diff --git a/packages/plugins/@nocobase/plugin-map/src/locale/zh-CN.json b/packages/plugins/@nocobase/plugin-map/src/locale/zh-CN.json index 38f0a8d79..f3b71faf6 100644 --- a/packages/plugins/@nocobase/plugin-map/src/locale/zh-CN.json +++ b/packages/plugins/@nocobase/plugin-map/src/locale/zh-CN.json @@ -1,51 +1,51 @@ { - "Map": "Map", - "Map-based geometry": "Map-based geometry", - "Map type": "Map type", - "Point": "Point", - "Line": "Line", - "Circle": "Circle", - "Polygon": "Polygon", - "Access key": "Access key", - "securityJsCode or serviceHost": "securityJsCode or serviceHost", - "AMap": "AMap", - "Google Maps": "Google Maps", - "Clear": "Clear", - "Click to select the starting point and double-click to end the drawing": "Click to select the starting point and double-click to end the drawing", - "Clear the canvas": "Clear the canvas", - "Are you sure to clear the canvas?": "Are you sure to clear the canvas?", - "Confirm": "Confirm", - "Cancel": "Cancel", - "Enter keywords to search": "Enter keywords to search", - "The AccessKey is incorrect, please check it": "The AccessKey is incorrect, please check it", - "Please configure the AMap securityCode or serviceHost correctly": "Please configure the AMap securityCode or serviceHost correctly", - "Map Manager": "Map Manager", - "Configuration": "Configuration", - "Saved successfully": "Saved successfully", - "Saved failed": "Saved failed", - "Edit": "Edit", - "Save": "Save", - "Please configure the AccessKey and SecurityJsCode first": "Please configure the AccessKey and SecurityJsCode first", - "Go to the configuration page": "Go to the configuration page", - "Zoom": "Zoom", - "Set default zoom level": "Set default zoom level", - "The default zoom level of the map": "The default zoom level of the map", - "Edit field title": "Edit field title", - "Field title": "Field title", - "Edit tooltip": "Edit tooltip", - "Delete field": "Delete field", - "Required": "Required", - "Pattern": "Pattern", - "Operator": "Operator", - "Editable": "Editable", - "Readonly": "Readonly", - "Easy-reading": "Easy-reading", - "Edit description": "Edit description", - "Map field": "Map field", - "Marker field": "Marker field", - "Load google maps failed, Please check the Api key and refresh the page": "Load google maps failed, Please check the Api key and refresh the page", - "Create map block": "Create map block", - "Start point": "Start point", - "End point": "End point", - "Concatenation order field": "Concatenation order field" + "Map": "地图", + "Map-based geometry": "基于地图的几何图形", + "Map type": "地图类型", + "Point": "点", + "Line": "线", + "Circle": "圆", + "Polygon": "多边形", + "Access key": "访问密钥", + "securityJsCode or serviceHost": "securityJsCode 或 serviceHost", + "AMap": "高德地图", + "Google Maps": "谷歌地图", + "Clear": "清空", + "Click to select the starting point and double-click to end the drawing": "点击选择起点,双击结束绘制", + "Clear the canvas": "清空画布", + "Are you sure to clear the canvas?": "您确定要清空画布吗?", + "Confirm": "确定", + "Cancel": "取消", + "Enter keywords to search": "输入地方名关键字搜索(必须包含省/市)", + "The AccessKey is incorrect, please check it": "访问密钥不正确,请检查", + "Please configure the AMap securityCode or serviceHost correctly": "请正确配置高德地图 securityCode 或 serviceHost", + "Map Manager": "地图管理", + "Configuration": "配置", + "Saved successfully": "保存成功", + "Saved failed": "保存失败", + "Edit": "编辑", + "Save": "保存", + "Please configure the AccessKey and SecurityJsCode first": "请先配置 AccessKey 和 SecurityJsCode", + "Go to the configuration page": "前往配置页面", + "Zoom": "缩放", + "Set default zoom level": "设置默认缩放级别", + "The default zoom level of the map": "地图默认缩放级别", + "Edit field title": "编辑字段标题", + "Field title": "字段标题", + "Edit tooltip": "编辑提示信息", + "Delete field": "删除字段", + "Required": "必填", + "Pattern": "模式", + "Operator": "运算符", + "Editable": "可编辑", + "Readonly": "只读(禁止编辑)", + "Easy-reading": "只读(阅读模式)", + "Edit description": "编辑描述", + "Map field": "地图字段", + "Marker field": "标记字段", + "Load google maps failed, Please check the Api key and refresh the page": "加载谷歌地图失败,请检查 Api key 并刷新页面", + "Create map block": "创建地图区块", + "Start point": "起点", + "End point": "终点", + "Concatenation order field": "连接顺序字段" }