modularize and localization

This commit is contained in:
Luis Riegger 2021-05-10 09:57:12 +02:00
parent 44f550fe92
commit 109ebbf162
4 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,7 @@
import { Characteristic, CharacteristicGetHandler, CharacteristicSetHandler, WithUUID } from "homebridge";
export declare interface CharacteristicHandler{
characteristic: WithUUID<new () => Characteristic>
getCharacteristicHandler?: CharacteristicGetHandler,
setCharacteristicHandler?: CharacteristicSetHandler
}

6
src/defaults.ts Normal file
View File

@ -0,0 +1,6 @@
import { RobotService } from "./models/services";
export const BACKGROUND_INTERVAL = 30;
export const PREFIX = false;
export const ALL_SERVICES = new Set(Object.values(RobotService));
export const LOCALE = "en"

57
src/localization.ts Normal file
View File

@ -0,0 +1,57 @@
export enum availableLocales {
EN = "en",
DE = "de",
FR = "fr",
}
const localizationDicts = {
'en': {
"clean": "Clean",
"cleanZone": "Clean Zone",
"cleanThe": "Clean the",
"goToDock": "Go to Dock",
"dockState": "Docked",
"binFull": "Bin Full",
"eco": "Eco Mode",
"noGoLines": "NoGo Lines",
"extraCare": "Extra Care",
"schedule": "Schedule",
"findMe": "Find me",
"cleanSpot": "Clean Spot",
"battery": "Battery"
},
'de': {
"clean": "Sauge",
"cleanZone": "Sauge Zone",
"cleanThe": "Sauge",
"goToDock": "Zur Basis",
"dockState": "In der Basis",
"binFull": "Behälter voll",
"eco": "Eco Modus",
"noGoLines": "NoGo Linien",
"extraCare": "Extra Care",
"schedule": "Zeitplan",
"findMe": "Finde mich",
"cleanSpot": "Spot Reinigung",
"battery": "Batterie"
},
'fr': {
"clean": "Aspirer",
"cleanZone": "Aspirer Zone",
"cleanThe": "Aspirer",
"goToDock": "Retour à la base",
"dockState": "Sur la base",
"binFull": "Conteneur plein",
"eco": "Eco mode",
"noGoLines": "Lignes NoGo",
"extraCare": "Extra Care",
"schedule": "Planifier",
"findMe": "Me retrouver",
"cleanSpot": "Nettoyage local",
"battery": "Batterie"
}
}
export function localize(label: string, locale: availableLocales) : string {
return localizationDicts[locale][label] ?? label
}

19
src/models/services.ts Normal file
View File

@ -0,0 +1,19 @@
export enum CleanType {
ALL,
SPOT,
}
export enum RobotService {
CLEAN = "clean",
CLEAN_SPOT = "cleanSpot",
CLEAN_ZONE = "cleanZone",
GO_TO_DOCK = "goToDock",
DOCKED = "dockState",
BIN_FULL = "binFull",
FIND_ME = "findMe",
SCHEDULE = "schedule",
ECO = "eco",
NOGO_LINES = "noGoLines",
EXTRA_CARE = "extraCare",
BATTERY = "battery",
}