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

fix: Add french translation missing #20061

Merged
merged 16 commits into from
Aug 30, 2022
Merged
5 changes: 3 additions & 2 deletions superset-frontend/src/dashboard/components/SliceAdder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
} from 'src/dashboard/util/constants';
import { slicePropShape } from 'src/dashboard/util/propShapes';
import { FILTER_BOX_MIGRATION_STATES } from 'src/explore/constants';
import moment from 'moment';
import AddSliceCard from './AddSliceCard';
import AddSliceDragPreview from './dnd/AddSliceDragPreview';
import DragDroppable from './dnd/DragDroppable';
Expand Down Expand Up @@ -221,7 +222,7 @@ class SliceAdder extends React.Component {
innerRef={dragSourceRef}
style={style}
sliceName={cellData.slice_name}
lastModified={cellData.changed_on_humanized}
lastModified={moment.utc(cellData.changed_on).fromNow()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be changed (@dpgaspar can comment in more detail, but IIRC, the changed_on property needs to be constructed in the backend right now)

Copy link
Contributor Author

@aehanno aehanno May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed_on_humanized has no translation. I will be glade to keep 'changed_on_humanized' but what can I change so that the translation is done

I move the change on this PR : #20082
we can discuss about that on the new PR

visType={cellData.viz_type}
datasourceUrl={cellData.datasource_url}
datasourceName={cellData.datasource_name}
Expand Down Expand Up @@ -253,7 +254,7 @@ class SliceAdder extends React.Component {
value={this.state.sortBy}
onChange={this.handleSelect}
options={Object.entries(KEYS_TO_SORT).map(([key, label]) => ({
label: t('Sort by %s', label),
label: t('Sort by %s', t(label)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right; you can't translate variables like this (the original code looks correct)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR: #20080

value: key,
}))}
placeholder={t('Sort by')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { DragLayer } from 'react-dnd';

import moment from 'moment';
import AddSliceCard from '../AddSliceCard';
import { slicePropShape } from '../../util/propShapes';
import {
Expand Down Expand Up @@ -72,7 +73,7 @@ function AddSliceDragPreview({ dragItem, slices, isDragging, currentOffset }) {
transform: `translate(${currentOffset.x}px, ${currentOffset.y}px)`,
}}
sliceName={slice.slice_name}
lastModified={slice.changed_on_humanized}
lastModified={moment.utc(slice.changed_on).fromNow()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

visType={slice.viz_type}
datasourceUrl={slice.datasource_url}
datasourceName={slice.datasource_name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export default function DateFilterLabel(props: DateFilterControlProps) {
<Divider />
<div>
<div className="section-title">{t('Actual time range')}</div>
{validTimeRange && <div>{evalResponse}</div>}
{validTimeRange && <div>{t(evalResponse)}</div>}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, you can't translate a variable (please see e.g. https://stackoverflow.com/questions/34579316/flask-babel-how-to-translate-variables for an explanation why this is the case)

Copy link
Contributor Author

@aehanno aehanno May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change has been move in this PR : #20080
We can discuss about translation of varaible in the ohter PR
Without the t() here, there is no translation, do you have an idea, where I can translate this

{!validTimeRange && (
<IconWrapper className="warning">
<Icons.ErrorSolidSmall iconColor={theme.colors.error.base} />
Expand Down Expand Up @@ -373,7 +373,7 @@ export default function DateFilterLabel(props: DateFilterControlProps) {
>
<Tooltip placement="top" title={tooltipTitle}>
<Label className="pointer" data-test="time-range-trigger">
{actualTimeRange}
{t(actualTimeRange)}
</Label>
</Tooltip>
</StyledPopover>
Expand Down
3 changes: 2 additions & 1 deletion superset-frontend/src/views/CRUD/chart/ChartCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { AntdDropdown } from 'src/components';
import { Menu } from 'src/components/Menu';
import FaveStar from 'src/components/FaveStar';
import FacePile from 'src/components/FacePile';
import moment from 'moment';
import { handleChartDelete, CardStyles } from '../utils';

interface ChartCardProps {
Expand Down Expand Up @@ -153,7 +154,7 @@ export default function ChartCard({
url={bulkSelectEnabled ? undefined : chart.url}
imgURL={chart.thumbnail_url || ''}
imgFallbackURL="/static/assets/images/chart-card-fallback.svg"
description={t('Modified %s', chart.changed_on_delta_humanized)}
description={t('Modified %s', moment(chart.changed_on_utc).fromNow())}
coverLeft={<FacePile users={chart.owners || []} />}
coverRight={
<Label type="secondary">{chart.datasource_name_text}</Label>
Expand Down
6 changes: 5 additions & 1 deletion superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Label from 'src/components/Label';
import FacePile from 'src/components/FacePile';
import FaveStar from 'src/components/FaveStar';
import { Dashboard } from 'src/views/CRUD/types';
import moment from 'moment';

interface DashboardCardProps {
isChart?: boolean;
Expand Down Expand Up @@ -162,7 +163,10 @@ function DashboardCard({
linkComponent={Link}
imgURL={dashboard.thumbnail_url}
imgFallbackURL="/static/assets/images/dashboard-card-fallback.svg"
description={t('Modified %s', dashboard.changed_on_delta_humanized)}
description={t(
'Modified %s',
moment(dashboard.changed_on_utc).fromNow(),
)}
coverLeft={<FacePile users={dashboard.owners || []} />}
actions={
<ListViewCard.Actions
Expand Down
4 changes: 3 additions & 1 deletion superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ListViewCard from 'src/components/ListViewCard';
import DeleteModal from 'src/components/DeleteModal';
import Icons from 'src/components/Icons';
import SubMenu from 'src/views/components/SubMenu';
import moment from 'moment';
import EmptyState from './EmptyState';
import {
CardContainer,
Expand All @@ -52,6 +53,7 @@ interface Query {
end_time?: string;
label?: string;
changed_on_delta_humanized?: string;
last_run?: string;
sql?: string | null;
}

Expand Down Expand Up @@ -316,7 +318,7 @@ const SavedQueries = ({
url={`/superset/sqllab?savedQueryId=${q.id}`}
title={q.label}
imgFallbackURL="/static/assets/images/empty-query.svg"
description={t('Ran %s', q.changed_on_delta_humanized)}
description={t('Ran %s', moment(q.last_run).fromNow())}
cover={
q?.sql?.length && showThumbnails && featureFlag ? (
<QueryContainer>
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/views/CRUD/welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
return (
<WelcomeContainer>
<WelcomeNav>
<h1 className="welcome-header">Home</h1>
<h1 className="welcome-header">{t('Home')}</h1>
aehanno marked this conversation as resolved.
Show resolved Hide resolved
{isFeatureEnabled(FeatureFlag.THUMBNAILS) ? (
<div className="switch">
<AntdSwitch checked={checked} onChange={handleToggle} />
Expand Down
40 changes: 20 additions & 20 deletions superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,26 @@ class TimeGrain(NamedTuple):


builtin_time_grains: Dict[Optional[str], str] = {
None: __("Original value"),
"PT1S": __("Second"),
"PT5S": __("5 second"),
"PT30S": __("30 second"),
"PT1M": __("Minute"),
"PT5M": __("5 minute"),
"PT10M": __("10 minute"),
"PT15M": __("15 minute"),
"PT30M": __("30 minute"),
"PT1H": __("Hour"),
"PT6H": __("6 hour"),
"P1D": __("Day"),
"P1W": __("Week"),
"P1M": __("Month"),
"P3M": __("Quarter"),
"P1Y": __("Year"),
"1969-12-28T00:00:00Z/P1W": __("Week starting Sunday"),
"1969-12-29T00:00:00Z/P1W": __("Week starting Monday"),
"P1W/1970-01-03T00:00:00Z": __("Week ending Saturday"),
"P1W/1970-01-04T00:00:00Z": __("Week_ending Sunday"),
None: _("Original value"),
"PT1S": _("Second"),
"PT5S": _("5 second"),
"PT30S": _("30 second"),
"PT1M": _("Minute"),
"PT5M": _("5 minute"),
"PT10M": _("10 minute"),
"PT15M": _("15 minute"),
"PT30M": _("30 minute"),
"PT1H": _("Hour"),
"PT6H": _("6 hour"),
"P1D": _("Day"),
"P1W": _("Week"),
"P1M": _("Month"),
"P3M": _("Quarter"),
"P1Y": _("Year"),
"1969-12-28T00:00:00Z/P1W": _("Week starting Sunday"),
"1969-12-29T00:00:00Z/P1W": _("Week starting Monday"),
"P1W/1970-01-03T00:00:00Z": _("Week ending Saturday"),
"P1W/1970-01-04T00:00:00Z": _("Week_ending Sunday"),
}


Expand Down
5 changes: 5 additions & 0 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.
"""A collection of ORM sqlalchemy models for SQL Lab"""
import re
import pytz
from datetime import datetime
from typing import Any, Dict, List

Expand Down Expand Up @@ -230,6 +231,10 @@ def pop_tab_link(self) -> Markup:
def user_email(self) -> str:
return self.user.email

@property
def last_run(self) -> str:
return self.changed_on.astimezone(pytz.utc).strftime("%Y-%m-%dT%H:%M:%S.%f%z")

@property
def sqlalchemy_uri(self) -> URL:
return self.database.sqlalchemy_uri
Expand Down
1 change: 1 addition & 0 deletions superset/queries/saved_queries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class SavedQueryRestApi(BaseSupersetModelRestApi):
"sql_tables",
"rows",
"last_run_delta_humanized",
"last_run",
"extra",
]
add_columns = ["db_id", "description", "label", "schema", "sql"]
Expand Down
Loading