From ca4b672beea95c804a18de8f891670560b06add9 Mon Sep 17 00:00:00 2001 From: Luis Riegger Date: Sun, 9 May 2021 18:34:46 +0200 Subject: [PATCH] fix localization logic --- src/accessories/koboldVacuumRobot.ts | 6 ++++-- src/defaults.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/accessories/koboldVacuumRobot.ts b/src/accessories/koboldVacuumRobot.ts index a564b97..758245b 100644 --- a/src/accessories/koboldVacuumRobot.ts +++ b/src/accessories/koboldVacuumRobot.ts @@ -2,7 +2,7 @@ import {CharacteristicValue, Logger, PlatformAccessory, PlatformAccessoryEvent, import {HomebridgeKoboldPlatform} from '../homebridgeKoboldPlatform'; import {Options} from '../models/options'; import { RobotService, CleanType } from '../models/services'; -import { ALL_SERVICES, BACKGROUND_INTERVAL, PREFIX } from '../defaults'; +import { ALL_SERVICES, BACKGROUND_INTERVAL, LOCALE, PREFIX } from '../defaults'; import { availableLocales, localize } from '../localization'; /** @@ -32,6 +32,7 @@ export class KoboldVacuumRobotAccessory // Config private readonly backgroundUpdateInterval: number; + private readonly locale: availableLocales; private readonly prefix: boolean; private readonly availableServices: Set; @@ -56,6 +57,7 @@ export class KoboldVacuumRobotAccessory this.backgroundUpdateInterval = KoboldVacuumRobotAccessory.parseBackgroundUpdateInterval(this.config['backgroundUpdate']); this.prefix = this.config['prefix'] || PREFIX; + this.locale = this.config['language'] || LOCALE; this.availableServices = new Set(this.config['services']) || ALL_SERVICES; this.isSpotCleaning = false; @@ -175,7 +177,7 @@ export class KoboldVacuumRobotAccessory private registerService(serviceName: RobotService, serviceType: WithUUID) : Service | undefined { - const displayName = this.prefix ? this.robot.name + serviceName : localize(serviceName, availableLocales.DE); + const displayName = this.prefix ? this.robot.name + serviceName : localize(serviceName, this.locale); // query existing service by type and subtype const existingService = this.accessory.getServiceById(serviceType, serviceName) diff --git a/src/defaults.ts b/src/defaults.ts index 5290cac..ae232fa 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -2,4 +2,5 @@ import { RobotService } from "./models/services"; export const BACKGROUND_INTERVAL = 30; export const PREFIX = false; -export const ALL_SERVICES = new Set(Object.values(RobotService)); \ No newline at end of file +export const ALL_SERVICES = new Set(Object.values(RobotService)); +export const LOCALE = "en" \ No newline at end of file