GT ClassMethodsTranslation

checkSetupStatus

API reference for the checkSetupStatus method to monitor project setup job progress

Overview

The checkSetupStatus method checks the current status of a project setup job using its unique identifier. This method is used to monitor the progress of asynchronous setup operations initiated by setupProject. Setup handles tasks such as corpus analysis, context generation, glossary generation, and more.

Setup runs automatically when elements of context are missing. This typically means that when you run translate for the first time, you will see a setup job running.

const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' });

const status = await gt.checkSetupStatus('setup-job-123');
console.log(`Setup status: ${status.status}`);

To check the status of a setup job, you must first have called both uploadSourceFiles and setupProject.

Reference

Parameters

NameTypeDescription
jobIdstringThe unique identifier of the setup job to check
timeoutMs?numberOptional timeout in milliseconds for the API request

Returns

Promise<CheckSetupStatusResult> – Contains the current job status and related information.

type CheckSetupStatusResult = {
  jobId: string;
  status: SetupJobStatus;
  error?: { message: string };
}
PropertyTypeDescription
jobIdstringThe identifier of the setup job that was checked
statusSetupJobStatusCurrent status of the setup job
error?{ message: string }Error information if the status is 'failed'

SetupJobStatus

type SetupJobStatus = 'queued' | 'processing' | 'completed' | 'failed';
  • 'queued' - Job is waiting to be processed
  • 'processing' - Job is currently being executed
  • 'completed' - Job completed successfully
  • 'failed' - Job encountered an error and failed

Example

Basic status checking

import { GT } from 'generaltranslation';

const gt = new GT({
  projectId: 'your-project-id',
  apiKey: 'your-api-key'
});


const fileRefs = [
  {
    fileId: 'file-123',
    versionId: 'version-456',
    fileName: 'app.json',
    fileFormat: 'JSON'
  },
  {
    fileId: 'file-789',
    versionId: 'version-012',
    fileName: 'content.md',
    fileFormat: 'MD'
  }
];

const setupResult = await gt.setupProject(fileRefs);

async function checkJobStatus(jobId: string) {
  const status = await gt.checkSetupStatus(jobId);
  
  console.log(`Job ${jobId}:`);
  console.log(`  Status: ${status.status}`);
  
  if (status.error) {
    console.log(`  Error: ${status.error.message}`);
  }
  
  return status;
}

const jobStatus = await checkJobStatus(setupResult.setupJobId);

Notes

  • Setup runs automatically when contextual elements are missing.
  • Setup handles corpus analysis, context generation, glossary generation, etc.
  • Job IDs are returned by setupProject and should be stored for status checking

Next steps

How is this guide?

checkSetupStatus