import Vue from 'vue' import VueI18n from 'vue-i18n' import ko from '@/locales/ko.json' import en from '@/locales/en.json' import ja from '@/locales/ja.json' Vue.use(VueI18n) function detectLocale() { try { const saved = localStorage.getItem('locale') if (saved) return saved } catch (e) { // ignore } const list = (navigator.languages && navigator.languages.length ? navigator.languages : [navigator.language || 'en']) .map(l => String(l).toLowerCase()) for (const l of list) { if (l.startsWith('ko')) return 'ko' if (l.startsWith('ja')) return 'ja' if (l.startsWith('en')) return 'en' } return 'en' // 매칭 실패 시 기본값 } const i18n = new VueI18n({ locale: detectLocale(), fallbackLocale: 'en', messages: { ko, en, ja }, // 숫자/통화 포맷 정책 numberFormats: { en: { decimal: { style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 2 }, currency: { style: 'currency', currency: 'USD', currencyDisplay: 'symbol', minimumFractionDigits: 2, maximumFractionDigits: 2 } }, ko: { decimal: { style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 2 }, currency: { style: 'currency', currency: 'KRW', currencyDisplay: 'symbol', minimumFractionDigits: 0, maximumFractionDigits: 0 } }, ja: { decimal: { style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 2 }, currency: { style: 'currency', currency: 'JPY', currencyDisplay: 'symbol', minimumFractionDigits: 0, maximumFractionDigits: 0 } } }, // 날짜/시간 포맷(예시) dateTimeFormats: { en: { short: { year: 'numeric', month: '2-digit', day: '2-digit' } }, ko: { short: { year: 'numeric', month: '2-digit', day: '2-digit' } }, ja: { short: { year: 'numeric', month: '2-digit', day: '2-digit' } } }, silentTranslationWarn: process.env.NODE_ENV === 'production', missing(locale, key) { if (process.env.NODE_ENV !== 'production') { // eslint-disable-next-line no-console console.warn(`[i18n missing] ${locale}: ${key}`) } } }) export default i18n