Dominator.js | CSS Property (Nesting)

A modern approach to DOM manipulation using Dominator Nesting

Translation with Dominator Nesting

Dominator.js provides a powerful and flexible way to handle translations using different approaches. This document explains how to implement translations in Dominator.js using nested properties, public methods, and direct execution methods.

1. Using the `translation` Property

Dominator.js allows developers to specify a translation property inside the object declaration. This approach makes translation seamless by automatically loading the language file before executing the callback function.

const translationObject = {
    file: 'swahili.json',
    filePath: translationFilePath,
    callback: swahiliProgram
};
D$({ translation: translationObject });

2. Using `D$.translation` Method

The `D$.translation` method directly loads the translation file and executes the specified callback function.

D$.translation(translationFilePath, swahiliProgram);

3. Using `D$.localization` Method

The `localization` method provides an additional layer of abstraction by allowing developers to load a language and then execute custom translations.

D$.localization(translationFilePath, () => {
    D$.swahili(translationFilePath, swahiliProgram);
});

4. Direct Execution Using Dominator

Dominator.js allows direct execution by passing both the callback function and the translation file path in a single statement.

D$(swahiliProgram, translationFilePath);