getProjectData
API-Referenz zur Methode getProjectData zum Abrufen von Projektinformationen und -konfiguration
Übersicht
Die Methode getProjectData ruft umfassende Informationen zu einem Übersetzungsprojekt ab, einschließlich Name, Organisation, Standardlocale und derzeit konfigurierter Ziel-locales.
Diese Methode ist nützlich, um 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(`Standard-Locale: ${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 Konfiguration für die Anfrage | 
Optionen
| Name | Typ | Beschreibung | 
|---|---|---|
| timeout? | number | Zeitüberschreitung der Anfrage in Millisekunden | 
Rückgabewert
Promise<ProjectData> – enthält Projektinformationen und Konfiguration.
type ProjectData = {
  id: string;
  name: string;
  orgId: string;
  defaultLocale: string;
  currentLocales: string[];
}| Eigenschaft | Typ | Beschreibung | 
|---|---|---|
| id | string | Eindeutige Projekt-ID | 
| name | string | Verständlicher Projektname | 
| orgId | string | ID der Organisation, der das Projekt gehört | 
| defaultLocale | string | Standard-Quell-Locale des Projekts | 
| currentLocales | string[] | Liste der aktuell konfigurierten Ziel-Locales | 
Beispiele
Grundlegende Verwendung
import { GT } from 'generaltranslation';
const gt = new GT({
  projectId: 'your-project-id',
  apiKey: 'your-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(`Standard-Locale: ${project.defaultLocale}`);
    console.log(`Ziel-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
- Projektdaten umfassen sowohl Quell- als auch Ziel-Locales-Konfigurationen
- Das Array currentLocalesumfasst alle für das Projekt konfigurierten Ziel-Locales
- Verwenden Sie diese Methode, um die Projektkonfiguration zu prü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 Übersetzungsaufträge zu starten
- Siehe querySourceFilefür dateispezifische Informationen
Wie ist dieser Leitfaden?

