// #region Imports
import { TranslatorServiceLocator } from '../Translations/TranslatorService';
/**
 * The `IntlController` class.
 *
 * @public
 */
export class IntlController {
    // #region Fields
    _host;
    _translator;
    _intl;
    _subscription;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `IntlController` class.
     *
     * @public
     */
    constructor(host, config) {
        this._host = host;
        this._translator = TranslatorServiceLocator.current;
        this._subscription = null;
        this._intl = config.factory();
        host.addController(this);
    }
    // #endregion
    // #region Properties
    /**
     * Gets the intl.
     *
     * @public
     */
    get intl() {
        return this._intl;
    }
    // #endregion
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this._subscription = this._translator.languageChanged.subscribe(() => {
            this._intl.changes.emit();
            this._host.requestUpdate();
        });
    }
    /**
     * @public
     */
    hostDisconnected() {
        this._subscription?.dispose();
    }
    /**
     * @public
     */
    setLocale(locale) {
        this._intl.locale = locale ?? 'default';
        this._host.requestUpdate();
    }
}
//# sourceMappingURL=IntlController.js.map