Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add distro translation #995

Merged
merged 2 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 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,9 @@ 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!]}_host`, [
shhdgit marked this conversation as resolved.
Show resolved Hide resolved
component,
])
const pathParams = (path_params ?? []).map((p) => {
p.required = true
return p
Expand Down
3 changes: 2 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,7 @@ 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!]}_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!],
})}
>
{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 }