Skip to content

Commit

Permalink
chore: add distro translation (pingcap#995)
Browse files Browse the repository at this point in the history
* chore: add distro translation

* fix: lowercase
  • Loading branch information
shhdgit committed Sep 2, 2021
1 parent a732a25 commit d21f58a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ui/lib/apps/DebugAPI/apilist/ApiForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
createFormWidget,
ParamModelType,
} from './widgets'
import { distro } from '@lib/utils/i18n'

export interface Topology {
tidb: TopologyTiDBInfo[]
Expand All @@ -33,7 +34,10 @@ export default function ApiForm({
const [form] = Form.useForm()
const { t } = useTranslation()
const { id, path_params, query_params, component } = endpoint
const endpointHostParamKey = useMemo(() => `${component}_host`, [component])
const endpointHostParamKey = useMemo(
() => `${distro[component!]?.toLowerCase()}_host`,
[component]
)
const pathParams = (path_params ?? []).map((p) => {
p.required = true
return p
Expand Down
5 changes: 4 additions & 1 deletion ui/lib/apps/DebugAPI/apilist/ApiList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import client, { EndpointAPIModel } from '@lib/client'
import style from './ApiList.module.less'
import ApiForm, { Topology } from './ApiForm'
import { buildQueryString } from './widgets'
import { distro } from '@lib/utils/i18n'

const getEndpointTranslationKey = (endpoint: EndpointAPIModel) =>
`debug_api.${endpoint.component}.endpoints.${endpoint.id}`
Expand Down Expand Up @@ -211,7 +212,9 @@ function Schema({ endpoint }: { endpoint: EndpointAPIModel }) {
const query = buildQueryString(endpoint.query_params ?? [])
return (
<p className={style.schema}>
{`http://{${endpoint.component}_host}${endpoint.path}${query}`}
{`http://{${distro[endpoint.component!]?.toLowerCase()}_host}${
endpoint.path
}${query}`}
</p>
)
}
3 changes: 2 additions & 1 deletion ui/lib/apps/DebugAPI/apilist/widgets/Host.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Select } from 'antd'
import { useTranslation } from 'react-i18next'

import type { ApiFormWidget } from './index'
import { distro } from '@lib/utils/i18n'

const portKeys: { [k: string]: string } = {
tidb: 'status_port',
Expand All @@ -20,7 +21,7 @@ export const HostSelectWidget: ApiFormWidget = ({ endpoint, topology }) => {
<Select
showSearch
placeholder={t(`debug_api.widgets.host_select_placeholder`, {
endpointType: endpoint.component,
endpointType: distro[endpoint.component!]?.toLowerCase(),
})}
>
{componentEndpoints.map((d) => {
Expand Down
2 changes: 2 additions & 0 deletions ui/lib/utils/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ i18next
defaultVariables: { distro },
},
})

export { distro }

0 comments on commit d21f58a

Please sign in to comment.