mirror of https://github.com/Lissy93/dashy.git
🔥 Adds language into Config handlers
This commit is contained in:
parent
1faa36f7df
commit
075e63f9b5
|
@ -11,6 +11,7 @@ import {
|
|||
pageInfo as defaultPageInfo,
|
||||
iconSize as defaultIconSize,
|
||||
layout as defaultLayout,
|
||||
language as defaultLanguage,
|
||||
} from '@/utils/defaults';
|
||||
|
||||
import conf from '../../public/conf.yml';
|
||||
|
@ -33,6 +34,8 @@ export default class ConfigAccumulator {
|
|||
|| appConfigFile.layout || defaultLayout;
|
||||
usersAppConfig.iconSize = localStorage[localStorageKeys.ICON_SIZE]
|
||||
|| appConfigFile.iconSize || defaultIconSize;
|
||||
usersAppConfig.language = localStorage[localStorageKeys.LANGUAGE]
|
||||
|| appConfigFile.language || defaultLanguage;
|
||||
return usersAppConfig;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue