/**
 * Set the language of WebViewer UI.
 * @method UI.setLanguage
 * @param {string} language The language WebViewer UI will use. By default, following languages are supported: en, zh_cn, fr.
 * @example
WebViewer(...)
  .then(function(instance) {
    instance.UI.setLanguage('zh-CN'); // set the language to 简体中文
  });
 */

import i18n from '../i18n'
const { locale } = i18n.global

export default (store) => (language) => {
  if (language !== 'zh-CN' && language !== 'en') {
    language = 'en'
  }
  locale.value = language
  store.setLanguage(language)
  window.localStorage.setItem('currentLanguage', language)
}
