Skip to content

Commit e2be95c

Browse files
committed
Publishing Localized Labels
1 parent 9436c5e commit e2be95c

4 files changed

Lines changed: 36 additions & 7 deletions

File tree

docs/hds-lib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/hds-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/tests-browser.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20340,7 +20340,9 @@ module.exports = function whichTypedArray(value) {
2034020340
/*!************************************!*\
2034120341
!*** ./src/HDSModel/HDSItemDef.js ***!
2034220342
\************************************/
20343-
/***/ ((module) => {
20343+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
20344+
20345+
const { localizeText } = __webpack_require__(/*! ../localizeText */ "./src/localizeText.js");
2034420346

2034520347
class HDSItemDef {
2034620348
#data;
@@ -20363,6 +20365,16 @@ class HDSItemDef {
2036320365
get data () {
2036420366
return this.#data;
2036520367
}
20368+
20369+
/** @type {string} label Localized */
20370+
get label () {
20371+
return localizeText(this.#data.label);
20372+
}
20373+
20374+
/** @type {string} description Localized */
20375+
get description () {
20376+
return localizeText(this.#data.description);
20377+
}
2036620378
}
2036720379

2036820380
module.exports = HDSItemDef;
@@ -20806,6 +20818,7 @@ class HDSService extends pryv.Service {
2080620818

2080720819
module.exports = HDSService;
2080820820

20821+
2080920822
/***/ }),
2081020823

2081120824
/***/ "./src/appTemplates/AppClientAccount.js":
@@ -22130,7 +22143,6 @@ async function initHDSModel (forceNew = false) {
2213022143
}
2213122144

2213222145

22133-
2213422146
/***/ }),
2213522147

2213622148
/***/ "./src/localizeText.js":
@@ -22169,7 +22181,7 @@ function getPreferredLocales () {
2216922181
* @returns {Array<string>}
2217022182
*/
2217122183
function getSupportedLocales () {
22172-
return [...preferredLocales];
22184+
return [...supportedLocales];
2217322185
}
2217422186

2217522187
/**
@@ -22328,6 +22340,7 @@ function getServiceInfoURL () {
2232822340
return serviceInfoUrl;
2232922341
}
2233022342

22343+
2233122344
/***/ }),
2233222345

2233322346
/***/ "./src/utils.js":
@@ -22739,6 +22752,7 @@ const { assert } = __webpack_require__(/*! ./test-utils/deps-node */ "./tests/te
2273922752
const modelURL = 'https://model.datasafe.dev/pack.json';
2274022753

2274122754
const { HDSModel } = __webpack_require__(/*! ../ */ "./src/index.js");
22755+
const { resetPreferredLocales, setPreferredLocales } = __webpack_require__(/*! ../src/localizeText */ "./src/localizeText.js");
2274222756

2274322757
describe('[MODX] Model', () => {
2274422758
let model;
@@ -22764,6 +22778,20 @@ describe('[MODX] Model', () => {
2276422778
});
2276522779

2276622780
// ---------- items ------------ //
22781+
describe('[MOLX] items localization', function () {
22782+
afterEach(() => {
22783+
// make sure locales are set back to default after each test
22784+
resetPreferredLocales();
22785+
});
22786+
it('[MOLL] Label & Description properties are localized', () => {
22787+
const itemDef = model.itemsDefs.forKey('body-weight');
22788+
assert.equal(itemDef.label, 'Body weight');
22789+
assert.equal(itemDef.description, 'Measured body weight');
22790+
setPreferredLocales(['fr']);
22791+
assert.equal(itemDef.label, 'Poids corporel');
22792+
assert.equal(itemDef.description, 'Poids corporel mesuré');
22793+
});
22794+
});
2276722795

2276822796
describe('[MOIX] items', function () {
2276922797
it('[MOIE] Throw error if itemsDefs.forKey not found', async () => {
@@ -23112,7 +23140,8 @@ const { assert } = __webpack_require__(/*! ./test-utils/deps-node */ "./tests/te
2311223140
const { resetPreferredLocales, getPreferredLocales, getSupportedLocales, localizeText, setPreferredLocales } = __webpack_require__(/*! ../src/localizeText */ "./src/localizeText.js");
2311323141

2311423142
describe('[LOCX] Lib settings', () => {
23115-
beforeEach(() => {
23143+
afterEach(() => {
23144+
// make sure locales are set back to default after each test
2311623145
resetPreferredLocales();
2311723146
});
2311823147

docs/tests-browser.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)