fix localization logic
This commit is contained in:
parent
4c00c67819
commit
ca4b672bee
@ -2,7 +2,7 @@ import {CharacteristicValue, Logger, PlatformAccessory, PlatformAccessoryEvent,
|
|||||||
import {HomebridgeKoboldPlatform} from '../homebridgeKoboldPlatform';
|
import {HomebridgeKoboldPlatform} from '../homebridgeKoboldPlatform';
|
||||||
import {Options} from '../models/options';
|
import {Options} from '../models/options';
|
||||||
import { RobotService, CleanType } from '../models/services';
|
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';
|
import { availableLocales, localize } from '../localization';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +32,7 @@ export class KoboldVacuumRobotAccessory
|
|||||||
|
|
||||||
// Config
|
// Config
|
||||||
private readonly backgroundUpdateInterval: number;
|
private readonly backgroundUpdateInterval: number;
|
||||||
|
private readonly locale: availableLocales;
|
||||||
private readonly prefix: boolean;
|
private readonly prefix: boolean;
|
||||||
private readonly availableServices: Set<RobotService>;
|
private readonly availableServices: Set<RobotService>;
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ export class KoboldVacuumRobotAccessory
|
|||||||
|
|
||||||
this.backgroundUpdateInterval = KoboldVacuumRobotAccessory.parseBackgroundUpdateInterval(this.config['backgroundUpdate']);
|
this.backgroundUpdateInterval = KoboldVacuumRobotAccessory.parseBackgroundUpdateInterval(this.config['backgroundUpdate']);
|
||||||
this.prefix = this.config['prefix'] || PREFIX;
|
this.prefix = this.config['prefix'] || PREFIX;
|
||||||
|
this.locale = this.config['language'] || LOCALE;
|
||||||
this.availableServices = new Set(this.config['services']) || ALL_SERVICES;
|
this.availableServices = new Set(this.config['services']) || ALL_SERVICES;
|
||||||
|
|
||||||
this.isSpotCleaning = false;
|
this.isSpotCleaning = false;
|
||||||
@ -175,7 +177,7 @@ export class KoboldVacuumRobotAccessory
|
|||||||
|
|
||||||
private registerService(serviceName: RobotService, serviceType: WithUUID<typeof Service>) : Service | undefined
|
private registerService(serviceName: RobotService, serviceType: WithUUID<typeof Service>) : 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
|
// query existing service by type and subtype
|
||||||
const existingService = this.accessory.getServiceById(serviceType, serviceName)
|
const existingService = this.accessory.getServiceById(serviceType, serviceName)
|
||||||
|
@ -2,4 +2,5 @@ import { RobotService } from "./models/services";
|
|||||||
|
|
||||||
export const BACKGROUND_INTERVAL = 30;
|
export const BACKGROUND_INTERVAL = 30;
|
||||||
export const PREFIX = false;
|
export const PREFIX = false;
|
||||||
export const ALL_SERVICES = new Set(Object.values(RobotService));
|
export const ALL_SERVICES = new Set(Object.values(RobotService));
|
||||||
|
export const LOCALE = "en"
|
Loading…
Reference in New Issue
Block a user