Class: SampleFileImporter

Class: SampleFileImporter

SampleFileImporter

new SampleFileImporter()

Import all Assets & Site files into the Language Service Provider.
The steps involved are:
  • For each site & assets file:
    • Load up and parse the file's JSON
    • Filter the file to remove all non-translatable strings
    • Handle empty files, these aren't sent to the Language Service Provider
    • Import the filtered non-empty file into the Language Service Provider and retrieve the documentId for the file.
    • Create a metadata file in the persistence store that contains the documentId for the file so the translated strings can be later merged with the original file
    • Wait for the file to be imported before continuing with the next file
Source:

Methods

importBinaryFile(jobConfig, projectId, file, fileType) → {Promise.<persistenceStore.fileMetadata>}

Import a binary file into the Language Service Provider.
The steps involved are:
  • For the binary file of each asset:
    • Import the binary file into the Language Service Provider and retrieve the documentId for the file.
    • Create a metadata file in the persistence store that contains the documentId for the file so the translated binary file can be later added to the translated package.
    • Wait for the file to be imported before continuing with the next file
Parameters:
Name Type Description
jobConfig SampleJobManager.JobConfig The configuration of the connector job to run. This information is held as metadata in the connector for the job.
projectId string The Language Service Provider project identifier corresponding to this job.
file SampleJobManager.file Details on the site or assets file to import
fileType 'site' | 'assets' The type of file being imported
Source:
Returns:
The metadata containing information about the file and the imported document created for the file
Type
Promise.<persistenceStore.fileMetadata>

importFile(jobConfig, projectId, file, fileType, contentTypes) → {Promise.<persistenceStore.fileMetadata>}

Import a file into the Language Service Provider.
The steps involved are:
  • For each site & assets file:
    • Load up and parse the file's JSON
    • Filter the file to remove all non-translatable strings
    • Handle empty files, these aren't sent to the Language Service Provider
    • Import the filtered non-empty file into the Language Service Provider and retrieve the documentId for the file.
    • Create a metadata file in the persistence store that contains the documentId for the file so the translated strings can be later merged with the original file
    • Wait for the file to be imported before continuing with the next file
Parameters:
Name Type Description
jobConfig SampleJobManager.JobConfig The configuration of the connector job to run. This information is held as metadata in the connector for the job.
projectId string The Language Service Provider project identifier corresponding to this job.
file SampleJobManager.file Details on the site or assets file to import
fileType 'site' | 'assets' The type of file being imported
contentTypes Array.<SampleJobManager.contentType> Array of content types.
Source:
Returns:
The metadata containing information about the file and the imported document created for the file
Type
Promise.<persistenceStore.fileMetadata>

importFileList(jobConfig, jobDetails, fileType, files, contentTypes) → {Array.<function()>}

Create a list of functions that returns a promise for each file in the list.
The promises are chained in a "return p1.then(return p2.then(return p3.then(...)))" model to avoid overloading the Language Service Provider.
Parameters:
Name Type Description
jobConfig SampleJobManager.JobConfig The configuration of the connector job to run. This information is held as metadata in the connector for the job.
jobDetails SampleJobManager.JobDetails The details of the combined job.json files.
fileType 'site' | 'assets' The type of file being imported
files Array.<SampleJobManager.file> Array of files to import.
contentTypes Array.<SampleJobManager.contentType> Array of content types.
Source:
Returns:
An array of functions, each of which returns a promise that resolves when the file is imported.
Type
Array.<function()>

importFiles(jobConfig, jobDetails) → {Promise}

Import all the Site & Assets files into the Language Service Provider for this job
The promises are chained in a "return p1.then(return p2.then(return p3.then(...)))" model to avoid overloading the Language Service Provider.
Parameters:
Name Type Description
jobConfig SampleJobManager.JobConfig The configuration of the connector job to run. This information is held as metadata in the connector for the job.
jobDetails SampleJobManager.JobDetails The details of the combined job.json files.
Source:
Returns:
A Promise that resolves when all files have been imported.
Type
Promise