Skip to content

BaseFramework Class

Defined in: framework/base/base.framework.ts:20

Abstract base class for framework-specific translation file management.

Type ParameterDescription
ResourceThe framework-specific data structure representing translation file contents. Returned by deserialize method for translation file content.
new BaseFramework<Resource>(config): BaseFramework<Resource>;

Defined in: framework/base/base.framework.ts:27

ParameterType
configStatic

BaseFramework<Resource>

PropertyTypeDescriptionDefined in
directorystringName of all source files directory (e.g. locales)framework/base/base.framework.ts:25
localestringName of source locale directory (e.g. en)framework/base/base.framework.ts:22
abstract deserialize(raw): Resource;

Defined in: framework/base/base.framework.ts:172

Parses raw translation file content into a framework-specific Resource object.

Implementations should parse the string and validate it against the framework’s resource schema, throwing an error if the format is invalid.

ParameterTypeDescription
rawstringTranslation file content as a string

Resource

Parsed and validated Resource object

Error if the content cannot be parsed or fails schema validation

abstract diff(oldResource): ResourceDelta[];

Defined in: framework/base/base.framework.ts:194

Computes translation differences between two Resource objects.

When oldResource is undefined, all keys in newResource should be marked as “added”.

ParameterTypeDescription
oldResource{ newResource: Resource; oldResource?: Resource; }The previous Resource state (undefined for newly created resources)
oldResource.newResourceResource-
oldResource.oldResource?Resource-

ResourceDelta[]

Array of ResourceDelta objects, each describing an added, changed, or removed translation key with its path and value(s)

diffSnapshots(__namedParameters): SnapshotDelta[];

Defined in: framework/base/base.framework.ts:82

Compares two snapshots to identify translation key-level changes across all files.

For each file present in the new snapshot, compares it against the old snapshot (if present) to detect added, changed, or removed translation keys

ParameterType
__namedParameters{ newSnapshot: Snapshot<Resource>; oldSnapshot: Snapshot<Resource>; }
__namedParameters.newSnapshotSnapshot<Resource>
__namedParameters.oldSnapshotSnapshot<Resource>

SnapshotDelta[]

Array of SnapshotDelta objects, each containing a file path and a ResourceDelta describing a specific translation change

abstract patch(resource): Resource;

Defined in: framework/base/base.framework.ts:214

Applies translation updates to a Resource object.

Implementations should iterate through the updates array and apply each value at its specified resourcePath

When resource is undefined, creates a new Resource and applies all updates to it.

ParameterTypeDescription
resource{ resource?: Resource; updates: Static<any>[]; }The existing Resource to modify (undefined to create a new one)
resource.resource?Resource-
resource.updatesStatic<any>[]-

Resource

The modified or newly created Resource object

abstract resolve(resource): string;

Defined in: framework/base/base.framework.ts:233

Retrieves the translation string value at a specific path within a Resource.

Implementations should traverse the Resource using the provided path array and return the string value found at that location.

ParameterTypeDescription
resource{ resource: Resource; resourcePath: Static; }The Resource object to query
resource.resourceResource-
resource.resourcePathStatic-

string

The translation string value at the specified path

Error if the resourcePath does not exist in the resource

resolveFilePath(filePath): string;

Defined in: framework/base/base.framework.ts:158

Resolves a file path relative to source locale directory to its absolute filesystem location for a given locale.

Combines the configured locales directory, target locale, and relative file path into an absolute path.

ParameterTypeDescription
filePath{ filePath: string; locale: string; }Relative path within the source locale directory (e.g., “common/buttons.json”)
filePath.filePathstring-
filePath.localestring-

string

Absolute filesystem path to the file (e.g., “/locales/fr/common/buttons.json”)

abstract serialize(resource): string;

Defined in: framework/base/base.framework.ts:182

Serializes a Resource object into formatted string content ready for file output.

Implementations should convert the Resource into a properly formatted string.

ParameterTypeDescription
resourceResourceThe Resource object to serialize

string

Formatted string content that can be written to a file

snapshot(locale?): Snapshot<Resource>;

Defined in: framework/base/base.framework.ts:43

Captures the current state of all translation files in the source locale directory.

Recursively traverses the directory at {directory}/{locale}, reads and deserializes each file, and returns a snapshot mapping relative file paths to their parsed contents.

ParameterType
locale?string

Snapshot<Resource>

Snapshot mapping file paths (relative to the source locale directory) to their deserialized Resource objects. For example, if a file exists at {directory}/{locale}/common/buttons.json, the key will be common/buttons.json.

Error if the source locale directory does not exist or files cannot be read