fix(bi): localization (#3159)

* fix(bi): localization

* fix: bug

* fix(map): localization

* fix: antd config provider
This commit is contained in:
YANG QIA 2023-12-07 21:15:40 +08:00 committed by GitHub
parent 1fddf0bcb5
commit 8708765f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 89 deletions

View File

@ -10,6 +10,7 @@ import {
Button, Button,
Cascader, Cascader,
CascaderProps, CascaderProps,
ConfigProvider,
Dropdown, Dropdown,
Empty, Empty,
MenuItemProps, MenuItemProps,
@ -952,6 +953,7 @@ export const SchemaSettingsModalItem: FC<SchemaSettingsModalItemProps> = (props)
const { theme } = useGlobalTheme(); const { theme } = useGlobalTheme();
const ctx = useContext(BlockRequestContext); const ctx = useContext(BlockRequestContext);
const upLevelActiveFields = useFormActiveFields(); const upLevelActiveFields = useFormActiveFields();
const { locale } = useContext(ConfigProvider.ConfigContext);
if (hidden) { if (hidden) {
return null; return null;
@ -988,7 +990,9 @@ export const SchemaSettingsModalItem: FC<SchemaSettingsModalItemProps> = (props)
`} `}
> >
<APIClientProvider apiClient={apiClient}> <APIClientProvider apiClient={apiClient}>
<SchemaComponent components={components} scope={scope} schema={schema} /> <ConfigProvider locale={locale}>
<SchemaComponent components={components} scope={scope} schema={schema} />
</ConfigProvider>
</APIClientProvider> </APIClientProvider>
</FormLayout> </FormLayout>
</SchemaComponentOptions> </SchemaComponentOptions>

View File

@ -24,6 +24,7 @@ import { Alert } from 'antd';
import { getPropsSchemaByComponent } from './utils'; import { getPropsSchemaByComponent } from './utils';
import { Field, onFieldValueChange } from '@formily/core'; import { Field, onFieldValueChange } from '@formily/core';
import { css, cx } from '@emotion/css'; import { css, cx } from '@emotion/css';
import { ConfigProvider } from 'antd';
const FieldComponentProps: React.FC = observer((props) => { const FieldComponentProps: React.FC = observer((props) => {
const form = useForm(); const form = useForm();
@ -78,6 +79,7 @@ export const ChartFilterFormItem = observer(
export const ChartFilterCustomItemInitializer: React.FC<{ export const ChartFilterCustomItemInitializer: React.FC<{
insert?: any; insert?: any;
}> = (props) => { }> = (props) => {
const { locale } = useContext(ConfigProvider.ConfigContext);
const { t: lang } = useChartsTranslation(); const { t: lang } = useChartsTranslation();
const t = useMemoizedFn(lang); const t = useMemoizedFn(lang);
const { scope, components } = useContext(SchemaOptionsContext); 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.')} message={t('To filter with custom fields, use "Current filter" variables in the chart configuration.')}
style={{ marginBottom: 16 }} style={{ marginBottom: 16 }}
/> />
<SchemaComponent <ConfigProvider locale={locale}>
schema={{ <SchemaComponent
properties: { schema={{
name: { properties: {
type: 'string', name: {
required: true, type: 'string',
required: true,
},
title: {
type: 'string',
title: t('Field title'),
'x-component': 'Input',
'x-decorator': 'FormItem',
required: true,
},
source: {
type: 'string',
title: t('Field source'),
'x-decorator': 'FormItem',
'x-component': 'Cascader',
enum: sourceFields,
description: t('Select a source field to use metadata of the field'),
},
component: {
type: 'string',
title: t('Field component'),
'x-component': 'Select',
'x-decorator': 'FormItem',
required: true,
enum: fieldComponents,
},
props: {
type: 'object',
title: t('Component properties'),
'x-component': 'FieldComponentProps',
},
}, },
title: { }}
type: 'string', />
title: t('Field title'), </ConfigProvider>
'x-component': 'Input',
'x-decorator': 'FormItem',
required: true,
},
source: {
type: 'string',
title: t('Field source'),
'x-decorator': 'FormItem',
'x-component': 'Cascader',
enum: sourceFields,
description: t('Select a source field to use metadata of the field'),
},
component: {
type: 'string',
title: t('Field component'),
'x-component': 'Select',
'x-decorator': 'FormItem',
required: true,
enum: fieldComponents,
},
props: {
type: 'object',
title: t('Component properties'),
'x-component': 'FieldComponentProps',
},
},
}}
/>
</FormLayout> </FormLayout>
</SchemaComponentOptions> </SchemaComponentOptions>
), ),

View File

@ -10,9 +10,9 @@ export const NAMESPACE = 'data-visualization';
// i18n.addResources('tr-TR', NAMESPACE, trTR); // i18n.addResources('tr-TR', NAMESPACE, trTR);
export function lang(key: string) { export function lang(key: string) {
return i18n.t(key, { ns: NAMESPACE }); return i18n.t(key, { ns: [NAMESPACE, 'client'] });
} }
export function useChartsTranslation() { export function useChartsTranslation() {
return useTranslation(NAMESPACE); return useTranslation([NAMESPACE, 'client'], { nsMode: 'fallback' });
} }

View File

@ -1,51 +1,51 @@
{ {
"Map": "Map", "Map": "地图",
"Map-based geometry": "Map-based geometry", "Map-based geometry": "基于地图的几何图形",
"Map type": "Map type", "Map type": "地图类型",
"Point": "Point", "Point": "",
"Line": "Line", "Line": "线",
"Circle": "Circle", "Circle": "",
"Polygon": "Polygon", "Polygon": "多边形",
"Access key": "Access key", "Access key": "访问密钥",
"securityJsCode or serviceHost": "securityJsCode or serviceHost", "securityJsCode or serviceHost": "securityJsCode serviceHost",
"AMap": "AMap", "AMap": "高德地图",
"Google Maps": "Google Maps", "Google Maps": "谷歌地图",
"Clear": "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", "Click to select the starting point and double-click to end the drawing": "点击选择起点,双击结束绘制",
"Clear the canvas": "Clear the canvas", "Clear the canvas": "清空画布",
"Are you sure to clear the canvas?": "Are you sure to clear the canvas?", "Are you sure to clear the canvas?": "您确定要清空画布吗?",
"Confirm": "Confirm", "Confirm": "确定",
"Cancel": "Cancel", "Cancel": "取消",
"Enter keywords to search": "Enter keywords to search", "Enter keywords to search": "输入地方名关键字搜索(必须包含省/市)",
"The AccessKey is incorrect, please check it": "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", "Please configure the AMap securityCode or serviceHost correctly": "请正确配置高德地图 securityCode 或 serviceHost",
"Map Manager": "Map Manager", "Map Manager": "地图管理",
"Configuration": "Configuration", "Configuration": "配置",
"Saved successfully": "Saved successfully", "Saved successfully": "保存成功",
"Saved failed": "Saved failed", "Saved failed": "保存失败",
"Edit": "Edit", "Edit": "编辑",
"Save": "Save", "Save": "保存",
"Please configure the AccessKey and SecurityJsCode first": "Please configure the AccessKey and SecurityJsCode first", "Please configure the AccessKey and SecurityJsCode first": "请先配置 AccessKey 和 SecurityJsCode",
"Go to the configuration page": "Go to the configuration page", "Go to the configuration page": "前往配置页面",
"Zoom": "Zoom", "Zoom": "缩放",
"Set default zoom level": "Set default zoom level", "Set default zoom level": "设置默认缩放级别",
"The default zoom level of the map": "The default zoom level of the map", "The default zoom level of the map": "地图默认缩放级别",
"Edit field title": "Edit field title", "Edit field title": "编辑字段标题",
"Field title": "Field title", "Field title": "字段标题",
"Edit tooltip": "Edit tooltip", "Edit tooltip": "编辑提示信息",
"Delete field": "Delete field", "Delete field": "删除字段",
"Required": "Required", "Required": "必填",
"Pattern": "Pattern", "Pattern": "模式",
"Operator": "Operator", "Operator": "运算符",
"Editable": "Editable", "Editable": "可编辑",
"Readonly": "Readonly", "Readonly": "只读(禁止编辑)",
"Easy-reading": "Easy-reading", "Easy-reading": "只读(阅读模式)",
"Edit description": "Edit description", "Edit description": "编辑描述",
"Map field": "Map field", "Map field": "地图字段",
"Marker 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", "Load google maps failed, Please check the Api key and refresh the page": "加载谷歌地图失败,请检查 Api key 并刷新页面",
"Create map block": "Create map block", "Create map block": "创建地图区块",
"Start point": "Start point", "Start point": "起点",
"End point": "End point", "End point": "终点",
"Concatenation order field": "Concatenation order field" "Concatenation order field": "连接顺序字段"
} }