mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
i18n: dashboard import page (#75664)
* add translation for filezone primary and secondary text * add translation for Grafana.com field label * update translation keys * add translation for load button * update required translation * Format utils for invalid-dashboard * add extracted translations * add pseudo translations * add translation for json validation * json field label translation * add translation for required json field * add translation for cancel key * add extracted translations * Add pseudo locale translation * Update public/app/features/manage-dashboards/utils/validation.ts Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/utils/validation.ts Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/utils/validation.ts Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/utils/validation.ts Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * update translations * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * Update public/app/features/manage-dashboards/DashboardImportPage.tsx Co-authored-by: Ashley Harrison <ashharrison90@gmail.com> * update link component * add new translations --------- Co-authored-by: Ashley Harrison <ashharrison90@gmail.com>
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { t } from 'i18next';
|
||||
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
|
||||
import { validationSrv } from '../services/ValidationSrv';
|
||||
@ -7,16 +9,16 @@ export const validateDashboardJson = (json: string) => {
|
||||
try {
|
||||
dashboard = JSON.parse(json);
|
||||
} catch (error) {
|
||||
return 'Not valid JSON';
|
||||
return t('dashboard.validation.invalid-json', 'Not valid JSON');
|
||||
}
|
||||
if (dashboard && dashboard.hasOwnProperty('tags')) {
|
||||
if (Array.isArray(dashboard.tags)) {
|
||||
const hasInvalidTag = dashboard.tags.some((tag: string) => typeof tag !== 'string');
|
||||
if (hasInvalidTag) {
|
||||
return 'tags expected array of strings';
|
||||
return t('dashboard.validation.tags-expected-strings', 'tags expected array of strings');
|
||||
}
|
||||
} else {
|
||||
return 'tags expected array';
|
||||
return t('dashboard.validation.tags-expected-array', 'tags expected array');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -26,7 +28,9 @@ export const validateGcomDashboard = (gcomDashboard: string) => {
|
||||
// From DashboardImportCtrl
|
||||
const match = /(^\d+$)|dashboards\/(\d+)/.exec(gcomDashboard);
|
||||
|
||||
return match && (match[1] || match[2]) ? true : 'Could not find a valid Grafana.com ID';
|
||||
return match && (match[1] || match[2])
|
||||
? true
|
||||
: t('dashboard.validation.invalid-dashboard-id', 'Could not find a valid Grafana.com ID');
|
||||
};
|
||||
|
||||
export const validateTitle = (newTitle: string, folderUid: string) => {
|
||||
|
Reference in New Issue
Block a user