getProjectData
API Reference zur Methode getProjectData, um Projektinformationen und Konfiguration abzurufen
Überblick
Die Methode getProjectData ruft umfassende Informationen zu einem Übersetzungsprojekt ab, darunter name, Organisation, Standard-locale und die aktuell konfigurierten Ziel-locales.
Diese Methode hilft dabei, die Projektkonfiguration nachzuvollziehen und Projekteinstellungen zu validieren.
const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' });
const projectData = await gt.getProjectData('project-123');
console.log(`Projekt: ${projectData.name}`);
console.log(`Standardlocale: ${projectData.defaultLocale}`);
console.log(`Ziel-Locales: ${projectData.currentLocales.join(', ')}`);Referenzen
Parameter
| Name | Typ | Beschreibung |
|---|---|---|
projectId | string | Die eindeutige Kennung des Projekts, das abgerufen werden soll |
options? | { timeout?: number } | Optionale Einstellungen für die Anfrage |
Optionen
| Name | Typ | Beschreibung |
|---|---|---|
timeout? | number | Anfrage-Timeout in Millisekunden |
Rückgabewerte
Promise<ProjectData> – Enthält Projektinformationen und -konfiguration.
type ProjectData = {
id: string;
name: string;
orgId: string;
defaultLocale: string;
currentLocales: string[];
}| Eigenschaft | Typ | Beschreibung |
|---|---|---|
id | string | Eindeutiger Projekt-Identifikator |
name | string | Verständlicher Projektname |
orgId | string | Identifikator der Organisation, der das Projekt gehört |
defaultLocale | string | Standard-Quell-locale des Projekts |
currentLocales | string[] | Array der derzeit konfigurierten Ziel-locales |
Beispiele
Grundlagen
import { GT } from 'generaltranslation';
const gt = new GT({
projectId: 'Ihre-project-id',
apiKey: 'Ihr-api-key'
});
async function getProjectInfo(projectId: string) {
try {
const project = await gt.getProjectData(projectId);
console.log('=== Projektinformationen ===');
console.log(`ID: ${project.id}`);
console.log(`Name: ${project.name}`);
console.log(`Organisation: ${project.orgId}`);
console.log(`Standardlocale: ${project.defaultLocale}`);
console.log(`Zielsprachen/-locales: ${project.currentLocales.join(', ')}`);
return project;
} catch (error) {
console.error(`Projekt ${projectId} konnte nicht abgerufen werden:`, error);
throw error;
}
}
const projectInfo = await getProjectInfo('my-project-123');Hinweise
- Die Methode bietet schreibgeschützten Zugriff auf Projektinformationen – verwenden Sie das Dashboard, um Projekteinstellungen zu ändern.
- Diese Methode erfordert eine gültige Projekt-ID – das Projekt muss mit dem bereitgestellten API-Schlüssel zugänglich sein.
- Die Projektdaten umfassen sowohl Quell- als auch Ziel-
locale-Konfigurationen. - Das Array
currentLocalesumfasst alle Ziel-locales, die für das Projekt konfiguriert sind. - Verwenden Sie diese Methode, um die Projektkonfiguration zu überprüfen, bevor Sie Übersetzungs-Workflows starten.
Nächste Schritte
- Siehe
shouldSetupProject, um zu prüfen, ob eine Projekteinrichtung erforderlich ist - Siehe
setupProject, um die Projekteinrichtung zu starten - Siehe
enqueueFiles, um Übersetzungsjobs zu starten - Siehe
querySourceFilefür dateispezifische Informationen
Wie ist diese Anleitung?