/**
 * Get a message by i18n id outside React (e.g. in axios interceptors, thunks).
 * Uses the same locale as I18nProvider (localStorage 'locale').
 */
import en from '../translations/en.json';
import zhHK from '../translations/zh-HK.json';
import zhCN from '../translations/zh-CN.json';

const messages = {
  en,
  'zh-HK': zhHK,
  zh: zhHK,
  'zh-CN': zhCN
};

export function getMessage(id) {
  const locale = localStorage.getItem('locale') || 'en';
  const m = messages[locale] || messages.en;
  return m[id] ?? messages.en[id] ?? id;
}
