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. Set up handles tasks like corpus analysis, context generation, glossary generation, etc.

Set up automatically runs 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 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 setup job identifier that was checked
statusSetupJobStatusCurrent status of the setup job
error?{ message: string }Error information if 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 finished 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

  • Set up automatically runs when elements of context are missing.
  • Set up is responsible for 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