HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/slfopp7cb1df/www/inventorypacket.com/resources/src/store/modules/language.js
import Vue from 'vue';
import VueLocalStorage from 'vue-localstorage';
import Languages from '../../translations';

Vue.use(VueLocalStorage);
const supportedLanguages = Object.getOwnPropertyNames(Languages);

export default {
  namespaced: true,
  state: {
    language: Vue.localStorage.get('language'),
  },
  mutations: {
    SET_LANGUAGE(state, lang) {
      Vue.localStorage.set('language', lang);
      state.language = lang;
    },
  },
  actions: {
    setLanguage({ commit }, languages) {
      if (typeof languages === 'string') {
        commit('SET_LANGUAGE', languages);
      } else {
        const language = supportedLanguages.find(sl =>
          languages.find(l => (l.split(new RegExp(sl, 'gi')).length - 1 > 0 ? sl : null)));
          commit('SET_LANGUAGE', language);
      }
    },
  },
};