import { language_pl_pl } from "../languages/pl_pl";

export class phrase {
    #text;
    static #dictionary;

    static #init() {
        phrase.#dictionary = language_pl_pl;
    }

    get dictionary() {
        if (!phrase.#dictionary) {
            phrase.#init()
        }

        return phrase.#dictionary;
    }

    constructor(location) {
        const splited = location.split(".");
        let dict = this.dictionary;

        for (let count in splited) {
            if (!(splited[count] in dict)) {
                this.#text = location;
                break;
            }

            dict = dict[splited[count]];
        }
        
        if (!this.#text) {    
            this.#text = dict;
        }
    }

    toString() {
        return this.#text;
    }

    get text() {
        return this.#text;
    }
}