Skip to content

Commit

Permalink
chore(translations): Add missing i18n (#17525)
Browse files Browse the repository at this point in the history
* Add *.ts to babel.cfg

* Add missing i18n calls

* Update pot file

* Fix lint issues and review comment

* Incorparate review feedback

* Fix missing or non-extractable i18n calls

* Update pot file

* Fix syntax error in CommonParameters.tsx

* Fix introduced issues
  • Loading branch information
hbruch authored Nov 27, 2021
1 parent 4cf429c commit 6604a6a
Show file tree
Hide file tree
Showing 22 changed files with 1,166 additions and 566 deletions.
4 changes: 1 addition & 3 deletions superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ export function postStopQuery(query) {
.then(() => dispatch(stopQuery(query)))
.then(() => dispatch(addSuccessToast(t('Query was stopped.'))))
.catch(() =>
dispatch(
addDangerToast(`${t('Failed at stopping query. ')}'${query.id}'`),
),
dispatch(addDangerToast(t('Failed at stopping query. %s', query.id))),
);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ class TabbedSqlEditors extends React.PureComponent {
);
const warning = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)
? ''
: `${t(
'-- Note: Unless you save your query, these tabs will NOT persist if you clear your cookies or change browsers.',
)}\n\n`;
: t(
'-- Note: Unless you save your query, these tabs will NOT persist if you clear your cookies or change browsers.\n\n',
);
const qe = {
title: t('Untitled Query %s', queryCount),
dbId:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function TemplateParamsEditor({
trigger={['hover']}
>
<div role="button">
{`${t('Parameters')} `}
{t('Parameters ')}
<Badge count={paramCount} />
{!isValid && (
<InfoTooltipWithTrigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ function DatabaseErrorMessage({

const copyText =
extra && extra.issue_codes
? `${message}
${t('This may be triggered by:')}
${extra.issue_codes.map(issueCode => issueCode.message).join('\n')}`
? t('%(message)s\nThis may be triggered by: \n%(issues)s', {
message,
issues: extra.issue_codes
.map(issueCode => issueCode.message)
.join('\n'),
})
: message;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ function TimeoutErrorMessage({
</>
);

const copyText = `${subtitle}
${t('This may be triggered by:')}
${extra.issue_codes.map(issueCode => issueCode.message).join('\n')}`;
const copyText = t('%(subtitle)s\nThis may be triggered by:\n %(issue)s', {
subtitle,
issue: extra.issue_codes.map(issueCode => issueCode.message).join('\n'),
});

return (
<ErrorAlert
Expand Down
5 changes: 4 additions & 1 deletion superset-frontend/src/components/Menu/MenuRight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ const RightMenu = ({
)}
</SubMenu>
)}
<SubMenu title="Settings" icon={<Icons.TriangleDown iconSize="xl" />}>
<SubMenu
title={t('Settings')}
icon={<Icons.TriangleDown iconSize="xl" />}
>
{settings.map((section, index) => [
<Menu.ItemGroup key={`${section.label}`} title={section.label}>
{section.childs?.map(child => {
Expand Down
4 changes: 1 addition & 3 deletions superset-frontend/src/dashboard/actions/dashboardState.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ export function saveDashboardRequest(data, id, saveType) {
getClientErrorObject(response).then(({ error }) =>
dispatch(
addDangerToast(
`${t(
'Sorry, there was an error saving this dashboard: ',
)} ${error}`,
t('Sorry, there was an error saving this dashboard: %s', error),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/dashboard/components/SliceAdder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,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')} ${label}`,
label: t('Sort by %s', label),
value: key,
}))}
placeholder={t('Sort by')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class SliceHeaderControls extends React.PureComponent<
const refreshTooltip = refreshTooltipData.map((item, index) => (
<div key={`tooltip-${index}`}>
{refreshTooltipData.length > 1
? `${t('Query')} ${index + 1}: ${item}`
? t('Query %s: %s', index + 1, item)
: item}
</div>
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ const FilterControls: FC<FilterControlsProps> = ({
`}
>
<Collapse.Panel
header={`${t('Filters out of scope')} (${
filtersOutOfScope.length
})`}
header={t('Filters out of scope (%d)', filtersOutOfScope.length)}
key="1"
>
{filtersOutOfScope.map(filter => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export const CALENDAR_RANGE_VALUES_SET = new Set(
);

const GRAIN_OPTIONS = [
{ value: 'second', label: (rel: string) => `${t('Seconds')} ${rel}` },
{ value: 'minute', label: (rel: string) => `${t('Minutes')} ${rel}` },
{ value: 'hour', label: (rel: string) => `${t('Hours')} ${rel}` },
{ value: 'day', label: (rel: string) => `${t('Days')} ${rel}` },
{ value: 'week', label: (rel: string) => `${t('Weeks')} ${rel}` },
{ value: 'month', label: (rel: string) => `${t('Months')} ${rel}` },
{ value: 'quarter', label: (rel: string) => `${t('Quarters')} ${rel}` },
{ value: 'year', label: (rel: string) => `${t('Years')} ${rel}` },
{ value: 'second', label: (rel: string) => t('Seconds %s', rel) },
{ value: 'minute', label: (rel: string) => t('Minutes %s', rel) },
{ value: 'hour', label: (rel: string) => t('Hours %s', rel) },
{ value: 'day', label: (rel: string) => t('Days %s', rel) },
{ value: 'week', label: (rel: string) => t('Weeks %s', rel) },
{ value: 'month', label: (rel: string) => t('Months %s', rel) },
{ value: 'quarter', label: (rel: string) => t('Quarters %s', rel) },
{ value: 'year', label: (rel: string) => t('Years %s', rel) },
];

export const SINCE_GRAIN_OPTIONS: SelectOptionType[] = GRAIN_OPTIONS.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const SelectAsyncControl = ({
const onError = (response: Response) =>
getClientErrorObject(response).then(e => {
const { error } = e;
addDangerToast(`${t('Error while fetching data')}: ${error}`);
addDangerToast(t('Error while fetching data: %s', error));
});
const loadOptions = () =>
SupersetClient.get({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {
const emptyFilter =
enableEmptyFilter && !inverseSelection && !values?.length;

const suffix =
inverseSelection && values?.length ? ` (${t('excluded')})` : '';
const suffix = inverseSelection && values?.length ? t(' (excluded)') : '';

dispatchDataMask({
type: 'filterState',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const hostField = ({
)}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.host}
placeholder="e.g. 127.0.0.1"
placeholder={t('e.g. 127.0.0.1')}
className="form-group-w-50"
label="Host"
label={t('Host')}
onChange={changeMethods.onParametersChange}
/>
);
Expand All @@ -64,7 +64,7 @@ export const portField = ({
value={db?.parameters?.port as number}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.port}
placeholder="e.g. 5432"
placeholder={t('e.g. 5432')}
className="form-group-w-50"
label="Port"
onChange={changeMethods.onParametersChange}
Expand All @@ -85,8 +85,8 @@ export const databaseField = ({
value={db?.parameters?.database}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.database}
placeholder="e.g. world_population"
label="Database name"
placeholder={t('e.g. world_population')}
label={t('Database name')}
onChange={changeMethods.onParametersChange}
helpText={t('Copy the name of the database you are trying to connect to.')}
/>
Expand All @@ -105,8 +105,8 @@ export const usernameField = ({
value={db?.parameters?.username}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.username}
placeholder="e.g. Analytics"
label="Username"
placeholder={t('e.g. Analytics')}
label={t('Username')}
onChange={changeMethods.onParametersChange}
/>
);
Expand All @@ -126,8 +126,8 @@ export const passwordField = ({
value={db?.parameters?.password}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.password}
placeholder="e.g. ********"
label="Password"
placeholder={t('e.g. ********')}
label={t('Password')}
onChange={changeMethods.onParametersChange}
/>
);
Expand Down Expand Up @@ -169,8 +169,8 @@ export const queryField = ({
value={db?.query_input || ''}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.query}
placeholder="e.g. param1=value1&param2=value2"
label="Additional Parameters"
placeholder={t('e.g. param1=value1&param2=value2')}
label={t('Additional Parameters')}
onChange={changeMethods.onQueryChange}
helpText={t('Add additional custom parameters')}
/>
Expand Down
Loading

0 comments on commit 6604a6a

Please sign in to comment.