const LOCALE_KEY = 'APP_LOCALE'

export function getStoredLocale() {
  try {
    const v = uni.getStorageSync(LOCALE_KEY)
    return v === 'bo' ? 'bo' : 'zh'
  } catch (e) {
    return 'zh'
  }
}

/** @param {'zh'|'bo'} code */
export function setStoredLocale(code) {
  const v = code === 'bo' ? 'bo' : 'zh'
  try {
    uni.setStorageSync(LOCALE_KEY, v)
  } catch (e) {
    /* ignore */
  }
  return v
}
