import enUS from './en_US.json'
import thTH from './th_TH.json'
import zhCN from './zh_CN.json'

import { createI18n } from 'vue-i18n'
import storage from "@/utils/storage.js"

const lang = storage.getCache('lang')

const defaultLocale = lang || 'zh_cn'

export const i18nConfig = {
	locale: defaultLocale,
	messages: {
		'en_us': enUS,
		'th_th': thTH,
		'zh_cn': zhCN,
	},
}

const i18n = createI18n(i18nConfig)

export const t = i18n.global.t

export function setLocale(locale) {
	i18n.global.locale = locale
}

export function setupI18n(app) {
	app.use(i18n)
}

export default i18n