AddonUtils

AddonUtils

new AddonUtils(objectToApply, overrideopt)

Description:
  • Represents a utility class for addons.

Source:
Parameters:
Name Type Attributes Default Description
objectToApply Object

The object to apply the utility methods and properties to.

override boolean <optional>
false

Indicates whether to override existing properties in the object.

Methods

(async, static) createProject(files, basePath, optionsopt) → {Promise.<Object>}

Description:
  • Creates a project based on provided files and options.

Source:
Parameters:
Name Type Attributes Default Description
files Array.<string>

An array of file names.

basePath string

The base path for the files.

options Object <optional>
{}

Additional options.

Returns:

A promise resolving to the created project data.

Type
Promise.<Object>

(async, static) createTransData(files, basePath, optionsopt) → {Promise.<TransData>}

Description:
  • Creates translation data for multiple files.

Source:
Parameters:
Name Type Attributes Default Description
files Array.<string>

An array of file names.

basePath string

The base path for the files.

options Object <optional>
{}

Additional options.

Returns:

A promise resolving to the translation data object.

Type
Promise.<TransData>

(async, static) exportAsZip(targetPath, transDataopt, optionsopt) → {Promise.<string>}

Description:
  • Exports translation data as a zip file.

Source:
Parameters:
Name Type Attributes Default Description
targetPath string

The target path for the zip file.

transData Object <optional>

The translation data object. If not provided, fetched from the current context.

options Object <optional>
{}

Additional options.

Returns:

A promise resolving to the path of the created zip file.

Type
Promise.<string>

(async, static) exportToFolder(destinationDir, transDataopt, optionsopt) → {Promise.<Array.<string>>}

Description:
  • Exports translation data to a folder.

Source:
Parameters:
Name Type Attributes Default Description
destinationDir string

The directory to export to.

transData Object <optional>

The translation data object. If not provided, fetched from the current context.

options Object <optional>
{}

Additional options.

Returns:

A promise resolving to an array of exported file paths.

Type
Promise.<Array.<string>>

(async, static) getTransData(file, basePath, optionsopt) → {Promise.<TransData>}

Description:
  • Retrieves translation data for a given file.

Source:
Parameters:
Name Type Attributes Default Description
file string

The name of the file.

basePath string

The base path for the file.

options Object <optional>
{}

Additional options.

Returns:

A promise resolving to the file data object containing data, context, tags, parameters, and indexIds.

Type
Promise.<TransData>

(async, static) handleExport(targetPath, options) → {Promise.<void>}

Description:
  • Handles exporting translation data based on the specified mode.

Source:
Parameters:
Name Type Description
targetPath string

The target path for the exported data.

options Object

Export options.

Properties
Name Type Description
mode string

The export mode ('zip' or 'directory').

Returns:

A promise resolving when export is completed.

Type
Promise.<void>

(async, static) writeFile(file, basePath, targetDir, optionsopt) → {Promise.<string>}

Description:
  • Writes a file with given translation.

Source:
Parameters:
Name Type Attributes Default Description
file string

The name of the file.

basePath string

The base path for the file.

targetDir string

The target directory.

options Object <optional>
{}

Additional options.

Returns:

A promise resolving to the path of the written file.

Type
Promise.<string>