Types

FileToTranslate

Type definition for file objects used in batch file translation operations

Overview

FileToTranslate represents a file object for batch translation operations with enqueueFiles.

type FileToTranslate = {
  content: string;
  fileName: string;
  fileFormat: FileFormat;
  formatMetadata?: Record<string, any>;
  dataFormat?: DataFormat;
};

Properties

PropertyTypeRequiredDescription
contentstringYesRaw file content
fileNamestringYesFile identifier
fileFormatFileFormatYesFile format
formatMetadata?Record<string, any>NoFormat-specific metadata
dataFormat?DataFormatNoData format within file
type FileFormat = 'JSON' | 'MDX' | 'MD' | 'HTML' | 'TXT' | string;
type DataFormat = 'JSX' | 'ICU' | 'I18NEXT';

Examples

JSON File

import { FileToTranslate } from 'generaltranslation';

const jsonFile: FileToTranslate = {
  content: JSON.stringify({
    "welcome": "Welcome",
    "save": "Save"
  }),
  fileName: 'common.json',
  fileFormat: 'JSON',
  dataFormat: 'I18NEXT'
};

MDX File

const mdxFile: FileToTranslate = {
  content: `# Getting Started\n\nWelcome to our platform!`,
  fileName: 'docs/start.mdx',
  fileFormat: 'MDX',
  dataFormat: 'JSX'
};

How is this guide?

FileToTranslate