mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Pass locale information through to plugins (#8917)
This commit is contained in:
parent
40c5910311
commit
37c8418f0e
@ -29,6 +29,8 @@ import { type UserStateProps, useUserState } from '../../states/UserState';
|
|||||||
* @param navigate - The navigation function (see react-router-dom)
|
* @param navigate - The navigation function (see react-router-dom)
|
||||||
* @param theme - The current Mantine theme
|
* @param theme - The current Mantine theme
|
||||||
* @param colorScheme - The current Mantine color scheme (e.g. 'light' / 'dark')
|
* @param colorScheme - The current Mantine color scheme (e.g. 'light' / 'dark')
|
||||||
|
* @param host - The current host URL
|
||||||
|
* @param locale - The current locale string (e.g. 'en' / 'de')
|
||||||
* @param context - Any additional context data which may be passed to the plugin
|
* @param context - Any additional context data which may be passed to the plugin
|
||||||
*/
|
*/
|
||||||
export type InvenTreeContext = {
|
export type InvenTreeContext = {
|
||||||
@ -38,6 +40,7 @@ export type InvenTreeContext = {
|
|||||||
userSettings: SettingsStateProps;
|
userSettings: SettingsStateProps;
|
||||||
globalSettings: SettingsStateProps;
|
globalSettings: SettingsStateProps;
|
||||||
host: string;
|
host: string;
|
||||||
|
locale: string;
|
||||||
navigate: NavigateFunction;
|
navigate: NavigateFunction;
|
||||||
theme: MantineTheme;
|
theme: MantineTheme;
|
||||||
colorScheme: MantineColorScheme;
|
colorScheme: MantineColorScheme;
|
||||||
@ -45,7 +48,7 @@ export type InvenTreeContext = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useInvenTreeContext = () => {
|
export const useInvenTreeContext = () => {
|
||||||
const host = useLocalState((s) => s.host);
|
const [locale, host] = useLocalState((s) => [s.language, s.host]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const user = useUserState();
|
const user = useUserState();
|
||||||
const { colorScheme } = useMantineColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
@ -57,6 +60,7 @@ export const useInvenTreeContext = () => {
|
|||||||
return {
|
return {
|
||||||
user: user,
|
user: user,
|
||||||
host: host,
|
host: host,
|
||||||
|
locale: locale,
|
||||||
api: api,
|
api: api,
|
||||||
queryClient: queryClient,
|
queryClient: queryClient,
|
||||||
navigate: navigate,
|
navigate: navigate,
|
||||||
@ -69,6 +73,7 @@ export const useInvenTreeContext = () => {
|
|||||||
user,
|
user,
|
||||||
host,
|
host,
|
||||||
api,
|
api,
|
||||||
|
locale,
|
||||||
queryClient,
|
queryClient,
|
||||||
navigate,
|
navigate,
|
||||||
globalSettings,
|
globalSettings,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user