🔥 Adds language into Config handlers

This commit is contained in:
Alicia Sykes
2021-07-24 21:39:14 +01:00
parent 1faa36f7df
commit 075e63f9b5
2 changed files with 22 additions and 1 deletions

View File

@@ -1,5 +1,11 @@
import ConfigAccumulator from '@/utils/ConfigAccumalator';
import { visibleComponents, localStorageKeys, theme as defaultTheme } from '@/utils/defaults';
import { languages } from '@/utils/languages';
import {
visibleComponents,
localStorageKeys,
theme as defaultTheme,
language as defaultLanguage,
} from '@/utils/defaults';
/**
* Initiates the Accumulator class and generates a complete config object
@@ -74,3 +80,15 @@ export const getCustomKeyShortcuts = () => {
});
return results.flat();
};
/**
* Gets the users chosen language. Defaults to English.
* @returns {object} Language, including code, name and flag
*/
export const getUsersLanguage = () => {
const langCode = localStorage[localStorageKeys.LANGUAGE]
|| config.appConfig.language
|| defaultLanguage;
const langObj = languages.find(lang => lang.code === langCode);
return langObj;
};