import store from './store.js' const locale = (await import(`./i18n/${store.get('locale') || 'zh-cn'}.js`)).default export default function(key, ...args){ try{ const msg = key.split('.').reduce((val, k) => val[k], locale); if(msg && args.length > 0){ return msg.replace(/\{(\d+)\}/g, (match, index) => args[index]) } return msg || key; } catch(e){ return key } }