chore: Localization of superset pt. 2 (#22772)

This commit is contained in:
Artem Shumeiko
2023-01-30 19:20:43 +03:00
committed by GitHub
parent b94052e438
commit c839d0daf5
60 changed files with 260 additions and 157 deletions

View File

@@ -1412,7 +1412,7 @@ export function popQuery(queryId) {
dbId: queryData.database.id,
schema: queryData.schema,
sql: queryData.sql,
name: `Copy of ${queryData.tab_name}`,
name: t('Copy of %s', queryData.tab_name),
autorun: false,
};
return dispatch(addQueryEditor(queryEditorProps));
@@ -1422,6 +1422,7 @@ export function popQuery(queryId) {
}
export function popDatasourceQuery(datasourceKey, sql) {
return function (dispatch) {
const QUERY_TEXT = t('Query');
const datasetId = datasourceKey.split('__')[0];
return SupersetClient.get({
endpoint: `/api/v1/dataset/${datasetId}?q=(keys:!(none))`,
@@ -1429,7 +1430,7 @@ export function popDatasourceQuery(datasourceKey, sql) {
.then(({ json }) =>
dispatch(
addQueryEditor({
name: `Query ${json.result.name}`,
name: `${QUERY_TEXT} ${json.result.name}`,
dbId: json.result.database.id,
schema: json.result.schema,
autorun: sql !== undefined,

View File

@@ -18,7 +18,7 @@
*/
import React from 'react';
import Label from 'src/components/Label';
import { STATE_TYPE_MAP } from 'src/SqlLab/constants';
import { STATE_TYPE_MAP, STATE_TYPE_MAP_LOCALIZED } from 'src/SqlLab/constants';
import { styled, Query } from '@superset-ui/core';
interface QueryStateLabelProps {
@@ -31,6 +31,8 @@ const StyledLabel = styled(Label)`
export default function QueryStateLabel({ query }: QueryStateLabelProps) {
return (
<StyledLabel type={STATE_TYPE_MAP[query.state]}>{query.state}</StyledLabel>
<StyledLabel type={STATE_TYPE_MAP[query.state]}>
{STATE_TYPE_MAP_LOCALIZED[query.state]}
</StyledLabel>
);
}

View File

@@ -360,8 +360,8 @@ const ResultSet = ({
message={t('%(rows)d rows returned', { rows })}
onClose={() => setAlertIsOpen(false)}
description={t(
'The number of rows displayed is limited to %s by the dropdown.',
rows,
'The number of rows displayed is limited to %(rows)d by the dropdown.',
{ rows },
)}
/>
</div>

View File

@@ -35,6 +35,7 @@ import {
STATUS_OPTIONS,
STATE_TYPE_MAP,
LOCALSTORAGE_MAX_QUERY_AGE_MS,
STATUS_OPTIONS_LOCALIZED,
} from '../../constants';
const TAB_HEIGHT = 140;
@@ -145,7 +146,7 @@ const SouthPane = ({
};
const renderOfflineStatus = () => (
<Label className="m-r-3" type={STATE_TYPE_MAP[STATUS_OPTIONS.offline]}>
{STATUS_OPTIONS.offline}
{STATUS_OPTIONS_LOCALIZED.offline}
</Label>
);

View File

@@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t } from '@superset-ui/core';
export const STATE_TYPE_MAP = {
offline: 'danger',
failed: 'danger',
@@ -26,6 +28,16 @@ export const STATE_TYPE_MAP = {
success: 'success',
};
export const STATE_TYPE_MAP_LOCALIZED = {
offline: t('offline'),
failed: t('failed'),
pending: t('pending'),
fetching: t('fetching'),
running: t('running'),
stopped: t('stopped'),
success: t('success'),
};
export const STATUS_OPTIONS = {
success: 'success',
failed: 'failed',
@@ -34,6 +46,14 @@ export const STATUS_OPTIONS = {
pending: 'pending',
};
export const STATUS_OPTIONS_LOCALIZED = {
success: t('success'),
failed: t('failed'),
running: t('running'),
offline: t('offline'),
pending: t('pending'),
};
export const TIME_OPTIONS = [
'now',
'1 hour ago',