Skip to content

Commit

Permalink
updated localizations and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thkl committed May 4, 2024
1 parent a64b35a commit b7397bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 79 deletions.
7 changes: 6 additions & 1 deletion lib/configurationsrv/localization/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,5 +446,10 @@
"ChangeLog": "ChangeLog",
"You are using this version": "Du benutzt diese Version",
"Datapoint which contains the battery level":"Datenpunkt welcher das Battie Level enthält",
"This service provides a battery indicator based on a HomeMatic Device Datapoint":"dieser Service stellt einen Batterie Indikator zur Verfügung"
"This service provides a battery indicator based on a HomeMatic Device Datapoint":"dieser Service stellt einen Batterie Indikator zur Verfügung",
"Datapoint":"Datenpunk",
"Max Level Value":"maximales Level",
"Use Color Temp":"Farbtemperatur verwenden",
"This will enable the color temperature feature. Please check in your CCU if your device supports this.":
"Dies wird die Farbtemperatureinstellung verwenden. Bitte prüfe in der CCU, ob das Gerät dies unterstützt"
}
89 changes: 11 additions & 78 deletions test/900_test_localizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,13 @@ describe('HAP-Homematic Localization Tests', () => {
this.regEx = /.__\('([^,][^']*)/g
this.regExIndex = /data-localize="(.*)"/g

let locFile = path.join(__dirname, '..', 'lib', 'configurationsrv', 'html', 'assets', 'de.json')
let locFile = path.join(__dirname, '..', 'lib', 'configurationsrv', 'localization', 'de.json')
if (fs.existsSync(locFile)) {
this.localizations = JSON.parse(fs.readFileSync(locFile))
this.localizations = JSON.parse(fs.readFileSync(locFile).toString())
this.localizations[''] = ' ' // add a dummy
console.log(`Using Localization from ${locFile}`);
}

it('HAP-Homematic check application.js', (done) => {
// load the file
let file = path.join(__dirname, '..', 'lib', 'configurationsrv', 'html', 'js', 'application.js')
if (fs.existsSync(file)) {
let content = fs.readFileSync(file)
var m
// split
do {
m = this.regEx.exec(content)
if (m) {
assert.ok(this.localizations[m[1]], m[1] + ' has no localization')
}
} while (m)
}

done()
})

it('HAP-Homematic check wizzard.js', (done) => {
// load the file
let file = path.join(__dirname, '..', 'lib', 'configurationsrv', 'html', 'js', 'wizzards.js')
if (fs.existsSync(file)) {
let content = fs.readFileSync(file)
var m
// split
do {
m = this.regEx.exec(content)
if (m) {
assert.ok(this.localizations[m[1]], m[1] + ' has no localization')
}
} while (m)
}

done()
})

it('HAP-Homematic check welcomewizzard.js', (done) => {
// load the file
let file = path.join(__dirname, '..', 'lib', 'configurationsrv', 'html', 'js', 'welcomewizzard.js')
if (fs.existsSync(file)) {
let content = fs.readFileSync(file)
var m
// split
do {
m = this.regEx.exec(content)
if (m) {
assert.ok(this.localizations[m[1]], m[1] + ' has no localization')
}
} while (m)
}

done()
})

it('HAP-Homematic check index.html', (done) => {
// load the file
let file = path.join(__dirname, '..', 'lib', 'configurationsrv', 'html', 'index.html')
if (fs.existsSync(file)) {
let content = fs.readFileSync(file)
var m
// split
do {
m = this.regExIndex.exec(content)
if (m) {
assert.ok(this.localizations[m[1]], m[1] + ' has no localization')
}
} while (m)
}

done()
})

it('HAP-Homematic check all service files ', (done) => {
// load the file

Expand All @@ -92,14 +21,18 @@ describe('HAP-Homematic Localization Tests', () => {
if (item.match(/HomeMatic.*Accessory.js/)) {
let test = require(path.join(__dirname, '..', 'lib', 'services', item))
let serviceDescription = test.serviceDescription()
assert.ok(this.localizations[serviceDescription], serviceDescription + ' has no localization')
assert.ok(this.localizations[serviceDescription] !== undefined, `serviceDescription ${serviceDescription} has no localization for ${item}`)
let configurationItems = test.configurationItems()
Object.keys(configurationItems).map((key) => {
let cItem = configurationItems[key]
// check label
assert.ok(this.localizations[cItem.label], cItem.label + ' has no localization')
// chekc hint
assert.ok(this.localizations[cItem.hint], cItem.hint + ' has no localization in ' + item)
if (cItem.label !== undefined) {
assert.ok(this.localizations[cItem.label], `Label for ${cItem.label} has no localization in ${item}`);
}
if (cItem.hint !== undefined) {
// chekc hint
assert.ok(this.localizations[cItem.hint], `Hint for ${cItem.hint} has no localization in ${item}`);
}
})
}
})
Expand Down

0 comments on commit b7397bb

Please sign in to comment.