From 109ebbf1627616a3f72a9478bdb294ed8162b817 Mon Sep 17 00:00:00 2001 From: Luis Riegger Date: Mon, 10 May 2021 09:57:12 +0200 Subject: [PATCH] modularize and localization --- src/characteristics/characteristicHandler.ts | 7 +++ src/defaults.ts | 6 +++ src/localization.ts | 57 ++++++++++++++++++++ src/models/services.ts | 19 +++++++ 4 files changed, 89 insertions(+) create mode 100644 src/characteristics/characteristicHandler.ts create mode 100644 src/defaults.ts create mode 100644 src/localization.ts create mode 100644 src/models/services.ts diff --git a/src/characteristics/characteristicHandler.ts b/src/characteristics/characteristicHandler.ts new file mode 100644 index 0000000..fbbc7f3 --- /dev/null +++ b/src/characteristics/characteristicHandler.ts @@ -0,0 +1,7 @@ +import { Characteristic, CharacteristicGetHandler, CharacteristicSetHandler, WithUUID } from "homebridge"; + +export declare interface CharacteristicHandler{ + characteristic: WithUUID Characteristic> + getCharacteristicHandler?: CharacteristicGetHandler, + setCharacteristicHandler?: CharacteristicSetHandler +} \ No newline at end of file diff --git a/src/defaults.ts b/src/defaults.ts new file mode 100644 index 0000000..ae232fa --- /dev/null +++ b/src/defaults.ts @@ -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" \ No newline at end of file diff --git a/src/localization.ts b/src/localization.ts new file mode 100644 index 0000000..185625b --- /dev/null +++ b/src/localization.ts @@ -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 +} \ No newline at end of file diff --git a/src/models/services.ts b/src/models/services.ts new file mode 100644 index 0000000..eb8dfab --- /dev/null +++ b/src/models/services.ts @@ -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", +}