import defaultLang from '../lang/zh_CN';
import { _config } from './setUnityGlobalLocale';
export const _t = (...args: any[]): string => {
  // 如果当前项目有 i18n 的 $t 方法注入，就使用它
  if (_config.$t) return _config.$t(...args);
  const [path] = args;
  const arr = path.split('.');
  let current: any = defaultLang,
    value = '',
    key: string;
  for (let i = 0, len = arr.length; i < len; i++) {
    key = arr[i];
    value = current[key];
    if (i === len - 1) return value;
    if (!value) return '';
    current = value;
  }
  return '';
};
