class I18n {
    static translate(text, values = {}) {
        if (!I18n.translations) {
            throw new Error("No translations loaded!");
        }

        if (!(text in I18n.translations)) {
            I18n.missingTranslations[text] = "";
        }

        let translation = I18n.locale == "PERUBIQUE" ? "PERUBIQUE" : (I18n.translations[text] ?? text);

        return translation.replace(
            /\{(\w+)\}/g,
            (_, key) => values[key] ?? `{${key}}`
        );
    }
}

function __(text, values = {}) {
    return I18n.translate(text, values);
}