Skip to content

Commit

Permalink
feat: [search] 新增国际化配置
Browse files Browse the repository at this point in the history
  • Loading branch information
hidden7123 authored and albyben committed Jul 31, 2024
1 parent 0388f21 commit e997f62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions components/locale/zh-CN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const locale = {
'Search.desc': ['空格代表"或",回车代表"且"'],
'Search.nplDesc': '智能搜索',
'Search.emptyTip': '暂无数据',
'Search.viewMoreResult': '查看更多"{inputValue}"的结果',
'Search.range': '范围',
'Search.or': '或',
'Filter.filterCondition': '筛选条件',
'Filter.commonCondition': '常用条件',
Expand Down
14 changes: 6 additions & 8 deletions components/search/search-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ const InternalSearchPanel: React.ForwardRefRenderFunction<ISearchPanelProps> = (
const searchPanelRef = (ref as any) || thisSearchPanelRef
const tooltipRef = useRef<HTMLDivElement>(null)

const {
locale: { getLangMsg },
} = useContext(ConfigContext)
const { locale } = useContext(ConfigContext)

const { prefixCls, className, style, placeholder, suffix, panelSearch = {} } = props

const searchLanMsg = locale.getCompLangMsg({ componentName: 'Search' })
const {
panelTypes,
panelResult = [],
Expand Down Expand Up @@ -121,7 +119,7 @@ const InternalSearchPanel: React.ForwardRefRenderFunction<ISearchPanelProps> = (
const rightContent = right || ''
return `${leftContent}${rightContent}`
}, [])

const getMoreInputValue = locale.getLangMsg('Search', 'viewMoreResult', { inputValue: inputValue })
return (
<>
<div ref={searchPanelRef} className={searchPanelCls} style={style}>
Expand All @@ -148,7 +146,7 @@ const InternalSearchPanel: React.ForwardRefRenderFunction<ISearchPanelProps> = (
</Tooltip>
</div>
<Input
placeholder={placeholder || getLangMsg('Search', 'placeholder')}
placeholder={placeholder || locale.getLangMsg('Search', 'placeholder')}
borderType="none"
allowClear
suffix={suffix}
Expand Down Expand Up @@ -207,10 +205,10 @@ const InternalSearchPanel: React.ForwardRefRenderFunction<ISearchPanelProps> = (
{typeof displayImg === 'string' ? <Image src={displayImg} preview={false} /> : displayImg}
</div>
<div className={`${prefixCls}-panel-dropDown-summary-title`}>
{result.id === 'search' ? `查看更多"${inputValue}"的搜索结果` : result.title}
{result.id === 'search' ? getMoreInputValue : result.title}
</div>
{result.id === 'search' ? (
<div className={`${prefixCls}-panel-dropDown-summary-list`}>{`范围: ${type.label}`}</div>
<div className={`${prefixCls}-panel-dropDown-summary-list`}>{`${searchLanMsg.range}: ${type.label}`}</div>
) : (
Object.keys(displayList).map((item: keyof typeof result, index) => (
<div key={index} className={`${prefixCls}-panel-dropDown-summary-list`}>
Expand Down

0 comments on commit e997f62

Please sign in to comment.