Added hotkeys + updated dependencies & webpack5 + humanetech badge (#15)
* Added language & theme switch hotkeys * Hotkeys testing * Language switch when equal * Shortcut keys changed * Dependencies updated & upgraded to webpack5 * Added HumaneTech badge * Disabled FLoC
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { languages, exceptions, mappings } from "./languages.json";
|
||||
import languagesJson from "./languages.json";
|
||||
const { languages, exceptions, mappings } = languagesJson;
|
||||
|
||||
const checkTypes = {
|
||||
exception: exceptions,
|
||||
@@ -32,15 +33,10 @@ export function replaceBoth(
|
||||
return { source, target };
|
||||
}
|
||||
|
||||
export function retrieveFiltered(source: string, target: string) {
|
||||
const current = {
|
||||
source: target,
|
||||
target: source
|
||||
};
|
||||
export function retrieveFiltered() {
|
||||
const [sourceLangs, targetLangs] = langTypes.map(type => (
|
||||
Object.entries(languages).filter(([code]) => (
|
||||
!Object.keys(exceptions[type]).includes(code)
|
||||
&& current[type] !== code
|
||||
))
|
||||
));
|
||||
return { sourceLangs, targetLangs };
|
||||
|
||||
@@ -33,17 +33,22 @@ type Action = {
|
||||
}
|
||||
|
||||
export default function reducer(state: State, action: Action) {
|
||||
const { source, target } = replaceBoth("exception", {
|
||||
source: state.target,
|
||||
target: state.source
|
||||
});
|
||||
|
||||
switch (action.type) {
|
||||
case Actions.SET_FIELD:
|
||||
const { key, value } = action.payload;
|
||||
if (key === "source" && value === state.target)
|
||||
return { ...state, [key]: value, target: target !== value ? target : "eo" };
|
||||
if (key === "target" && value === state.source)
|
||||
return { ...state, [key]: value, source };
|
||||
return { ...state, [key]: value };
|
||||
case Actions.SET_ALL:
|
||||
return { ...state, ...action.payload.state };
|
||||
case Actions.SWITCH_LANGS:
|
||||
const { source, target } = replaceBoth("exception", {
|
||||
source: state.target,
|
||||
target: state.source
|
||||
});
|
||||
return {
|
||||
...state,
|
||||
source: source !== target
|
||||
|
||||
Reference in New Issue
Block a user