"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const XEUtils = require("xe-utils");
const core = require("./core.js");
const i18nStore = require("./i18nStore.js");
const configStore = require("./configStore.js");
let checkInstall = false;
let cacheMaps = {};
function getI18n(key, args) {
  const { langMaps, language } = i18nStore.i18nConfigStore;
  const { i18n } = configStore.globalConfigStore;
  if (i18n) {
    return `${i18n(key, args) || ""}`;
  }
  if (!checkInstall) {
    if (!langMaps[language]) {
      console.error(`[vxe core] 语言包未安装。Language not installed. https://${core.VxeCore.uiVersion ? "vxeui.com" : "vxetable.cn"}/#/start/i18n`);
    }
    checkInstall = true;
  }
  if (!args && cacheMaps[key]) {
    return cacheMaps[key];
  }
  const i18nLabel = XEUtils.toFormatString(XEUtils.get(langMaps[language], key, key), args);
  if (!args) {
    cacheMaps[key] = i18nLabel;
  }
  return i18nLabel;
}
function setLanguage(locale) {
  const { language } = i18nStore.i18nConfigStore;
  const targetlang = locale || "zh-CN";
  if (language !== targetlang) {
    i18nStore.i18nConfigStore.language = targetlang;
    cacheMaps = {};
  }
  return core.VxeCore;
}
function setI18n(locale, data) {
  i18nStore.i18nConfigStore.langMaps[locale] = Object.assign({}, data);
  return core.VxeCore;
}
function hasLanguage(language) {
  const { langMaps } = i18nStore.i18nConfigStore;
  return !!langMaps[language];
}
function getLanguage() {
  const { language } = i18nStore.i18nConfigStore;
  return language;
}
exports.getI18n = getI18n;
exports.getLanguage = getLanguage;
exports.hasLanguage = hasLanguage;
exports.setI18n = setI18n;
exports.setLanguage = setLanguage;
