<commit_before>import Vue from 'vue';

import zhLang from './lang/zh-CN';
import enLang from './lang/en-US';
import utils from '../utils/utils';
import Format from '../utils/format';

const format = Format(Vue);
let lang = zhLang;
const langs = {
  zh: zhLang,
  en: enLang
}
let merged = {};
let i18nHandler = function () {
  const vuei18n = this.$i18n;
  if (vuei18n && vuei18n.locale) {
    if (!merged[vuei18n.locale]) {
      merged[vuei18n.locale] = true;
      let localMessage = vuei18n.getLocaleMessage(vuei18n.locale) || {};
      let newLocalMessage = {};
      utils.extend(true, newLocalMessage, langs[vuei18n.locale], localMessage);
      vuei18n.setLocaleMessage(vuei18n.locale, newLocalMessage);
    }
    return vuei18n.t(...arguments);
  }
};

const t = function (path, options) {
  let value = i18nHandler.apply(this, arguments);
  if (value !== null && value !== undefined) return value;

  const array = path.split('.');
  let current = lang;

  for (let i = 0, j = array.length; i < j; i++) {
    const property = array[i];
    value = current[property];
    if (i === j - 1) return format(value, options);
    if (!value) return '';
    current = value;
  }<commit_msg>fix: update lang when use i18n<commit_after>import Vue from 'vue';

import zhLang from './lang/zh-CN';
import enLang from './lang/en-US';
import utils from '../utils/utils';
import Format from '../utils/format';

const format = Format(Vue);
let lang = zhLang;
const langs = {
  zh: zhLang,
  en: enLang
}
let merged = {};
let i18nHandler = function () {
  const vuei18n = this.$i18n;
  if (vuei18n && vuei18n.locale) {
    if (!merged[vuei18n.locale]) {
      merged[vuei18n.locale] = true;
      let localMessage = vuei18n.getLocaleMessage(vuei18n.locale) || {};
      let newLocalMessage = {};
      utils.extend(true, newLocalMessage, langs[vuei18n.locale], localMessage);
      lang = newLocalMessage;
      vuei18n.setLocaleMessage(vuei18n.locale, newLocalMessage);
    }
    return vuei18n.t(...arguments);
  }
};

const t = function (path, options) {
  let value = i18nHandler.apply(this, arguments);
  if (value !== null && value !== undefined) return value;

  const array = path.split('.');
  let current = lang;

  for (let i = 0, j = array.length; i < j; i++) {
    const property = array[i];
    value = current[property];
    if (i === j - 1) return format(value, options);
    if (!value) return '';
    current = value;
  }
{'fraction_non_alphanumeric': 0.15590292060880295, 'fraction_numerical': 0.025503907856849032, 'mean_word_length': 3.335115864527629, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6845166', 'n_tokens_mistral': 880, 'n_tokens_neox': 839, 'n_words': 223}