<commit_before>import { BaseApp, Plugin, PluginConfig, Log, Handler, HandleRequest } from "jovo-core";
import { I18Next } from "jovo-cms-i18next";

import * as path from 'path';
import _merge = require('lodash.merge');

export interface Config extends PluginConfig {
    intentMap?: {
        [key: string]: string;
    };
    i18n?: {
        resources: {
            [key: string]: { // locale
                translation: {
                    [key: string]: string; // actual key value pair specifying the response
                };
                AlexaSkill: {
                    [key: string]: string;
                };
                GoogleAction: {
                    [key: string]: string;
                };
            };
        };
    };
}

export interface Response {
    status: 'SUCCESSFUL' | 'REJECTED' | 'ERROR';
    data: {
        [key: string]: any; // tslint:disable-line
    };
}

export class Component implements Plugin {
    config: Config = {};
    handler: Handler = {};
    pathToI18n?: string; // path to dir containing i18n files
    name?: string;
    $response?: Response;
    onCompletedIntent?: string; // intent to which the component routes to, when it sends out response
    i18next?: I18Next;

    constructor(config?: Config) {
        if (config) {
            this.config = _merge(this.config, config);
        }    
    }

    install(app: BaseApp) {
        // load components i18n files before setup as in setup the i18n object is initialized
        app.middleware('before.setup')!.use(this.loadI18nFiles.bind(this));
        app.middleware('after.platform.init')!.use(this.initialize.bind(this));

        this.i18next = new I18Next();
    }
    
    uninstall() {

    }

    /**
     * Adds the components i18n files to the $cms.I18Next object
     * @param handleRequest 
     */
    async loadI18nFiles(handleRequest: HandleRequest) {
        // add user specified i18n resources
        if (this.config.i18n) {
            this.i18next!.config.resources = this.config.i18n.resources;
        }

        const pathToComponent = `../components/${this.name}/`;<commit_msg>:ok_hand: Removes feature to overwrite component's i18n resources in root config 6c5899dd91336da089926b02056164d196ebb416<commit_after>import { BaseApp, Plugin, PluginConfig, Log, Handler, HandleRequest } from "jovo-core";
import { I18Next } from "jovo-cms-i18next";

import * as path from 'path';
import _merge = require('lodash.merge');

export interface Config extends PluginConfig {
    intentMap?: {
        [key: string]: string;
    };
}

export interface Response {
    status: 'SUCCESSFUL' | 'REJECTED' | 'ERROR';
    data: {
        [key: string]: any; // tslint:disable-line
    };
}

export class Component implements Plugin {
    config: Config = {};
    handler: Handler = {};
    pathToI18n?: string; // path to dir containing i18n files
    name?: string;
    $response?: Response;
    onCompletedIntent?: string; // intent to which the component routes to, when it sends out response
    i18next?: I18Next;

    constructor(config?: Config) {
        if (config) {
            this.config = _merge(this.config, config);
        }    
    }

    install(app: BaseApp) {
        // load components i18n files before setup as in setup the i18n object is initialized
        app.middleware('before.setup')!.use(this.loadI18nFiles.bind(this));
        app.middleware('after.platform.init')!.use(this.initialize.bind(this));

        this.i18next = new I18Next();
    }
    
    uninstall() {

    }

    /**
     * Adds the components i18n files to the $cms.I18Next object
     * @param handleRequest 
     */
    async loadI18nFiles(handleRequest: HandleRequest) {
        const pathToComponent = `../components/${this.name}/`;
{'fraction_non_alphanumeric': 0.11972391823732413, 'fraction_numerical': 0.026015396867533847, 'mean_word_length': 2.3763440860215055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '401417', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1083, 'n_words': 293}