{"size": 1514, "ext": "js", "max_stars_repo_path": "bin/GameLang.js", "max_stars_repo_name": "mazemasterjs/game-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bin/GameLang.js", "max_issues_repo_name": "mazemasterjs/game-server", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bin/GameLang.js", "max_forks_repo_name": "mazemasterjs/game-server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 36.9268292683, "max_line_length": 125, "alphanum_fraction": 0.5898282695}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const funcs_1 = require("./funcs");
class GameLang {
    constructor() { }
    static getInstance(langCode) {
        const method = `getInstance(${langCode})`;
        // instantiate the class instance, if needed
        if (this.instance === undefined) {
            this.instance = new GameLang();
            this.instance.loadLanguages();
        }
        const lang = this.languages.find(item => {
            return item.language === langCode;
        });
        if (lang === undefined) {
            funcs_1.logTrace(__filename, method, `No language defined for code '${langCode}' - defaulting to English (en)!`);
            return this.languages.find(item => {
                return item.language === 'en';
            });
        }
        return lang;
    }
    loadLanguages() {
        const langs = ['es', 'en'];
        for (const lang of langs) {
            const file = path_1.default.resolve(`data/${lang}.json`);
            const data = JSON.parse(fs_1.default.readFileSync(file, 'UTF-8'));
            GameLang.languages.push(data);
        }
    }
}
GameLang.languages = new Array();
exports.GameLang = GameLang;
exports.default = GameLang;
//# sourceMappingURL=GameLang.js.map