Internationalisation: Enable i18n eslint rules (#104277)

* enable i18n rules by default

* commit translation changes
This commit is contained in:
Ashley Harrison
2025-04-22 13:56:25 +01:00
committed by GitHub
parent 94e24f44b9
commit b052b28a88
10 changed files with 50 additions and 91 deletions
-17
View File
@@ -108,21 +108,4 @@ module.exports = [
'no-barrel-files/no-barrel-files': 'error',
},
},
{
files: ['public/**/*.tsx', 'packages/grafana-ui/**/*.tsx'],
ignores: ['public/app/plugins/**', '**/*.story.tsx', '**/*.{test,spec}.{ts,tsx}', '**/__mocks__/', 'public/test'],
rules: {
'@grafana/no-untranslated-strings': [
'error',
{
forceFix: [
// Add paths here that are happy to be auto fixed by this rule,
// for example
// 'public/app/features/alerting'
],
},
],
'@grafana/no-translation-top-level': 'error',
},
},
];
-20
View File
@@ -1116,9 +1116,6 @@ exports[`better eslint`] = {
"public/app/features/connections/tabs/ConnectData/NoAccessModal/index.tsx:5381": [
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"]
],
"public/app/features/connections/tabs/ConnectData/Search/Search.tsx:5381": [
[0, 0, 0, "Do not use the t() function outside of a component or function", "0"]
],
"public/app/features/connections/tabs/ConnectData/Search/index.tsx:5381": [
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"]
],
@@ -1656,15 +1653,6 @@ exports[`better eslint`] = {
"public/app/features/dimensions/utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/explore/RichHistory/RichHistorySettingsTab.tsx:5381": [
[0, 0, 0, "Do not use the t() function outside of a component or function", "0"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "1"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "2"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "3"]
],
"public/app/features/explore/ShortLinkButtonMenu.tsx:5381": [
[0, 0, 0, "Do not use the t() function outside of a component or function", "0"]
],
"public/app/features/explore/TraceView/TraceView.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
@@ -1778,14 +1766,6 @@ exports[`better eslint`] = {
"public/app/features/inspector/InspectDataTab.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
],
"public/app/features/inspector/InspectJSONTab.tsx:5381": [
[0, 0, 0, "Do not use the t() function outside of a component or function", "0"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "1"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "2"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "3"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "4"],
[0, 0, 0, "Do not use the t() function outside of a component or function", "5"]
],
"public/app/features/inspector/InspectStatsTab.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
],
+4 -2
View File
@@ -47,6 +47,7 @@ module.exports = [
'public/vendor/',
'scripts/grafana-server/tmp',
'!.betterer.eslint.config.js',
'packages/grafana-ui/src/graveyard', // deprecated UI components slated for removal
],
},
// Conditionally run the betterer rules if enabled in dev's config
@@ -275,10 +276,11 @@ module.exports = [
plugins: {
'@grafana': grafanaPlugin,
},
files: ['public/app/features/alerting/**/*.{ts,tsx,js,jsx}'],
ignores: ['**/*.{spec,test}.tsx'],
files: ['public/**/*.{ts,tsx,js,jsx}', 'packages/grafana-ui/**/*.{ts,tsx,js,jsx}'],
ignores: ['public/app/plugins/**', '**/*.story.tsx', '**/*.{test,spec}.{ts,tsx}', '**/__mocks__/', 'public/test'],
rules: {
'@grafana/no-untranslated-strings': 'error',
'@grafana/no-translation-top-level': 'error',
},
},
{
@@ -19,8 +19,6 @@ const getStyles = (theme: GrafanaTheme2, headerHeight: number) => ({
}),
});
const placeholder = t('connections.search.placeholder', 'Search all');
export interface Props {
onChange: (e: React.FormEvent<HTMLInputElement>) => void;
value: string | undefined;
@@ -29,6 +27,7 @@ export interface Props {
export const Search = ({ onChange, value }: Props) => {
const chromeHeaderHeight = useChromeHeaderHeight();
const styles = useStyles2(getStyles, chromeHeaderHeight ?? 0);
const placeholder = t('connections.search.placeholder', 'Search all');
return (
<div className={styles.searchContainer}>
@@ -1,6 +0,0 @@
import { t } from 'app//core/internationalization';
export const i18n = {
queryLibrary: t('explore.rich-history.query-library', 'Query library'),
queryHistory: t('explore.rich-history.query-history', 'Query history'),
};
@@ -16,7 +16,6 @@ import { RichHistoryQuery } from 'app/types/explore';
import { supportedFeatures } from '../../../core/history/richHistoryStorageProvider';
import { Tabs } from '../QueriesDrawer/QueriesDrawerContext';
import { i18n } from '../QueriesDrawer/utils';
import { selectExploreDSMaps } from '../state/selectors';
import { RichHistoryQueriesTab } from './RichHistoryQueriesTab';
@@ -94,7 +93,7 @@ export function RichHistory(props: RichHistoryProps) {
.filter((name): name is string => !!name);
const QueriesTab: TabConfig = {
label: i18n.queryHistory,
label: t('explore.rich-history.query-history', 'Query history'),
value: Tabs.RichHistory,
content: (
<RichHistoryQueriesTab
@@ -42,13 +42,6 @@ const getStyles = (theme: GrafanaTheme2) => {
};
};
const retentionPeriodOptions = [
{ value: 2, label: t('explore.rich-history-settings-tab.retention-period.2-days', '2 days') },
{ value: 5, label: t('explore.rich-history-settings-tab.retention-period.5-days', '5 days') },
{ value: 7, label: t('explore.rich-history-settings-tab.retention-period.1-week', '1 week') },
{ value: 14, label: t('explore.rich-history-settings-tab.retention-period.2-weeks', '2 weeks') },
];
export function RichHistorySettingsTab(props: RichHistorySettingsProps) {
const {
retentionPeriod,
@@ -60,6 +53,12 @@ export function RichHistorySettingsTab(props: RichHistorySettingsProps) {
deleteRichHistory,
} = props;
const styles = useStyles2(getStyles);
const retentionPeriodOptions = [
{ value: 2, label: t('explore.rich-history-settings-tab.retention-period.2-days', '2 days') },
{ value: 5, label: t('explore.rich-history-settings-tab.retention-period.5-days', '5 days') },
{ value: 7, label: t('explore.rich-history-settings-tab.retention-period.1-week', '1 week') },
{ value: 14, label: t('explore.rich-history-settings-tab.retention-period.2-weeks', '2 weeks') },
];
const selectedOption = retentionPeriodOptions.find((v) => v.value === retentionPeriod);
const onDelete = () => {
@@ -26,16 +26,15 @@ interface ShortLinkMenuItemData {
absTime: boolean;
}
const defaultMode: ShortLinkMenuItemData = {
key: 'copy-link',
label: t('explore.toolbar.copy-shortened-link', 'Copy shortened URL'),
icon: 'share-alt',
getUrl: () => undefined,
shorten: true,
absTime: false,
};
export function ShortLinkButtonMenu() {
const defaultMode: ShortLinkMenuItemData = {
key: 'copy-link',
label: t('explore.toolbar.copy-shortened-link', 'Copy shortened URL'),
icon: 'share-alt',
getUrl: () => undefined,
shorten: true,
absTime: false,
};
const panes = useSelector(selectPanes);
const [isOpen, setIsOpen] = useState(false);
const [lastSelected, setLastSelected] = useState(defaultMode);
@@ -26,30 +26,6 @@ enum ShowContent {
DataFrames = 'frames',
}
const options: Array<SelectableValue<ShowContent>> = [
{
label: t('dashboard.inspect-json.panel-json-label', 'Panel JSON'),
description: t(
'dashboard.inspect-json.panel-json-description',
'The model saved in the dashboard JSON that configures how everything works.'
),
value: ShowContent.PanelJSON,
},
{
label: t('dashboard.inspect-json.panel-data-label', 'Panel data'),
description: t('dashboard.inspect-json.panel-data-description', 'The raw model passed to the panel visualization'),
value: ShowContent.PanelData,
},
{
label: t('dashboard.inspect-json.dataframe-label', 'DataFrame JSON (from Query)'),
description: t(
'dashboard.inspect-json.dataframe-description',
'Raw data without transformations and field config applied. '
),
value: ShowContent.DataFrames,
},
];
interface Props {
onClose: () => void;
dashboard?: DashboardModel;
@@ -58,6 +34,35 @@ interface Props {
}
export function InspectJSONTab({ panel, dashboard, data, onClose }: Props) {
const options: Array<SelectableValue<ShowContent>> = useMemo(
() => [
{
label: t('dashboard.inspect-json.panel-json-label', 'Panel JSON'),
description: t(
'dashboard.inspect-json.panel-json-description',
'The model saved in the dashboard JSON that configures how everything works.'
),
value: ShowContent.PanelJSON,
},
{
label: t('dashboard.inspect-json.panel-data-label', 'Panel data'),
description: t(
'dashboard.inspect-json.panel-data-description',
'The raw model passed to the panel visualization'
),
value: ShowContent.PanelData,
},
{
label: t('dashboard.inspect-json.dataframe-label', 'DataFrame JSON (from Query)'),
description: t(
'dashboard.inspect-json.dataframe-description',
'Raw data without transformations and field config applied. '
),
value: ShowContent.DataFrames,
},
],
[]
);
const styles = useStyles2(getPanelInspectorStyles2);
const jsonOptions = useMemo(() => {
if (panel) {
@@ -67,7 +72,7 @@ export function InspectJSONTab({ panel, dashboard, data, onClose }: Props) {
return options;
}
return options.slice(1, options.length);
}, [panel]);
}, [options, panel]);
const [show, setShow] = useState(panel ? ShowContent.PanelJSON : ShowContent.DataFrames);
const [text, setText] = useState('');
-1
View File
@@ -4781,7 +4781,6 @@
"newest-first": "Newest first",
"oldest-first": "Oldest first",
"query-history": "Query history",
"query-library": "Query library",
"settings": "Settings",
"starred": "Starred"
},