24 lines
560 B
TypeScript
24 lines
560 B
TypeScript
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
export type SupportedLocale = 'id' | 'cn';
|
|
|
|
interface LocaleState {
|
|
currentLocale: SupportedLocale;
|
|
}
|
|
|
|
const initialState: LocaleState = {
|
|
currentLocale: 'id', // Default to Indonesian
|
|
};
|
|
|
|
export const localeSlice = createSlice({
|
|
name: "locale",
|
|
initialState,
|
|
reducers: {
|
|
setLocale: (state, action: PayloadAction<SupportedLocale>) => {
|
|
state.currentLocale = action.payload;
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { setLocale } = localeSlice.actions;
|
|
export default localeSlice.reducer; |