Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • oss/libraries/javascript/monster
1 result
Select Git revision
Loading items
Show changes
Commits on Source (5)
<a name="v3.28.0"></a>
## [v3.28.0] - 2023-03-14
### Add Features
- customcontrol.updatei18n can now plural rules
### Changes
- update packages
<a name="v3.27.0"></a> <a name="v3.27.0"></a>
## [v3.27.0] - 2023-03-14 ## [v3.27.0] - 2023-03-14
### Add Features ### Add Features
...@@ -422,6 +431,7 @@ ...@@ -422,6 +431,7 @@
<a name="1.8.0"></a> <a name="1.8.0"></a>
## 1.8.0 - 2021-08-15 ## 1.8.0 - 2021-08-15
[v3.28.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.27.0...v3.28.0
[v3.27.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.26.0...v3.27.0 [v3.27.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.26.0...v3.27.0
[v3.26.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.25.0...v3.26.0 [v3.26.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.25.0...v3.26.0
[v3.25.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.24.0...v3.25.0 [v3.25.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.24.0...v3.25.0
......
import {Embed} from '@schukai/monster/source/i18n/providers/embed.mjs'; import {Embed} from '@schukai/monster/source/i18n/providers/embed.mjs';
// read from scritp tag with id i18n // read from script tag with id i18n
const translation = new Embed('i18n'); const translation = new Embed('i18n');
{ {
"name": "@schukai/monster", "name": "@schukai/monster",
"version": "3.26.0", "version": "3.27.0",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.", "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [ "keywords": [
"framework", "framework",
......
...@@ -295,24 +295,44 @@ class CustomElement extends HTMLElement { ...@@ -295,24 +295,44 @@ class CustomElement extends HTMLElement {
* Before you can use this method, you must have loaded the translations. * Before you can use this method, you must have loaded the translations.
* *
* @returns {Monster.DOM.CustomElement} * @returns {Monster.DOM.CustomElement}
* @throws {Error} Cannot find element with translations. Add a translations object to the document.
*/ */
updateI18n() { updateI18n() {
const translations = getDocumentTranslations(); const translations = getDocumentTranslations();
if (!translations) { if (!translations) {
return this; return this;
} }
const labels = this.getOption("labels"); let labels = this.getOption("labels");
if (!isIterable(labels)) { if (!(isObject(labels) || isIterable(labels))) {
return this; return this;
} }
for (const key in labels) { for (const key in labels) {
const text = translations.getText(key, labels[key]); const def = labels[key];
if (text !== labels[key]) {
if (isString(def)) {
const text = translations.getText(key, def);
if (text !== def) {
this.setOption("labels." + key, text); this.setOption("labels." + key, text);
} }
continue;
} else if (isObject(def)) {
for (const k in def) {
const d = def[k];
const text = translations.getPluralRuleText(key, k, d);
if (!isString(text)) {
throw new Error("Invalid labels definition");
}
if (text !== d) {
this.setOption("labels." + key + "." + k, text);
}
}
continue;
}
throw new Error("Invalid labels definition");
} }
return this; return this;
......
...@@ -104,7 +104,7 @@ class Translations extends Base { ...@@ -104,7 +104,7 @@ class Translations extends Base {
} else { } else {
count = validateInteger(count); count = validateInteger(count);
if (count === 0) { if (count === 0) {
// special handlig for zero count // special handling for zero count
if (r.hasOwnProperty("zero")) { if (r.hasOwnProperty("zero")) {
return validateString(r["zero"]); return validateString(r["zero"]);
} }
......
...@@ -142,7 +142,7 @@ function getMonsterVersion() { ...@@ -142,7 +142,7 @@ function getMonsterVersion() {
} }
/** don't touch, replaced by make with package.json version */ /** don't touch, replaced by make with package.json version */
monsterVersion = new Version("3.26.0"); monsterVersion = new Version("3.27.0");
return monsterVersion; return monsterVersion;
} }
{ {
"name": "monster", "name": "monster",
"version": "3.26.0", "version": "3.27.0",
"description": "monster", "description": "monster",
"repository": { "repository": {
"type": "git", "type": "git",
......
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module" src="main.mjs"></script>
</head>
<body>
<h1>Updater</h1>
<script type="application/json" data-monster-role="translations">
{
"theListContainsNoEntries": "translation1",
"key2": {
"other": "translation2"
},
"multi": {
"two": "translation3"
}
}
</script>
<monster-1>Monster1</monster-1>
</body>
</html>
import {Fetch} from '../../../application/source/i18n/providers/fetch.mjs';
import {Updater} from '../../../application/source/dom/updater.mjs';
import {CustomElement, registerCustomElement} from '../../../application/source/dom/customelement.mjs';
import {domReady} from '../../../application/source/dom/ready.mjs';
import {Embed} from '../../../application/source/i18n/providers/embed.mjs';
class Monster1 extends CustomElement {
get defaults() {
return Object.assign(
{},
super.defaults,
{
labels: {
theListContainsNoEntries: "The list contains no entries",
multi: {
zero: "Zero",
one: "One",
two: "Two",
few: "Few",
many: "Many",
other: "Other"
}
}
});
};
/**
*
* @return {string}
*/
static getTag() {
return "monster-1";
}
}
domReady.then(() => {
Embed.assignTranslationsToElement().then(() => {
m1.updateI18n();
console.log(m1.getOption('labels'));
console.log(m1.getOption('labels.multi.two'));
});
const translation = new Embed('i18n');
const m1 = document.querySelector("monster-1");
// read from scritp tag with id i18n
});
registerCustomElement(Monster1);
//
// const provider = new Fetch('translation.json', {
// method: 'GET',
// headers: {
// 'Content-Type': 'application/json',
// },
// });
//
// provider
// .assignToElement()
// .then(() => {
// new Updater(document.body, {}).run();
// })
// .catch((e) => {
// console.error(e);
// });
{
"key1": "value1",
"key2": "value2"
}
\ No newline at end of file
...@@ -808,12 +808,12 @@ packages: ...@@ -808,12 +808,12 @@ packages:
- '@types/node' - '@types/node'
dev: true dev: true
/@microsoft/api-extractor-model/7.26.4_@types+node@18.15.2: /@microsoft/api-extractor-model/7.26.4_@types+node@18.15.3:
resolution: {integrity: sha512-PDCgCzXDo+SLY5bsfl4bS7hxaeEtnXj7XtuzEE+BtALp7B5mK/NrS2kHWU69pohgsRmEALycQdaQPXoyT2i5MQ==} resolution: {integrity: sha512-PDCgCzXDo+SLY5bsfl4bS7hxaeEtnXj7XtuzEE+BtALp7B5mK/NrS2kHWU69pohgsRmEALycQdaQPXoyT2i5MQ==}
dependencies: dependencies:
'@microsoft/tsdoc': 0.14.2 '@microsoft/tsdoc': 0.14.2
'@microsoft/tsdoc-config': 0.16.2 '@microsoft/tsdoc-config': 0.16.2
'@rushstack/node-core-library': 3.55.2_@types+node@18.15.2 '@rushstack/node-core-library': 3.55.2_@types+node@18.15.3
transitivePeerDependencies: transitivePeerDependencies:
- '@types/node' - '@types/node'
dev: true dev: true
...@@ -838,14 +838,14 @@ packages: ...@@ -838,14 +838,14 @@ packages:
- '@types/node' - '@types/node'
dev: true dev: true
/@microsoft/api-extractor/7.34.4_@types+node@18.15.2: /@microsoft/api-extractor/7.34.4_@types+node@18.15.3:
resolution: {integrity: sha512-HOdcci2nT40ejhwPC3Xja9G+WSJmWhCUKKryRfQYsmE9cD+pxmBaKBKCbuS9jUcl6bLLb4Gz+h7xEN5r0QiXnQ==} resolution: {integrity: sha512-HOdcci2nT40ejhwPC3Xja9G+WSJmWhCUKKryRfQYsmE9cD+pxmBaKBKCbuS9jUcl6bLLb4Gz+h7xEN5r0QiXnQ==}
hasBin: true hasBin: true
dependencies: dependencies:
'@microsoft/api-extractor-model': 7.26.4_@types+node@18.15.2 '@microsoft/api-extractor-model': 7.26.4_@types+node@18.15.3
'@microsoft/tsdoc': 0.14.2 '@microsoft/tsdoc': 0.14.2
'@microsoft/tsdoc-config': 0.16.2 '@microsoft/tsdoc-config': 0.16.2
'@rushstack/node-core-library': 3.55.2_@types+node@18.15.2 '@rushstack/node-core-library': 3.55.2_@types+node@18.15.3
'@rushstack/rig-package': 0.3.18 '@rushstack/rig-package': 0.3.18
'@rushstack/ts-command-line': 4.13.2 '@rushstack/ts-command-line': 4.13.2
colors: 1.2.5 colors: 1.2.5
...@@ -1117,7 +1117,7 @@ packages: ...@@ -1117,7 +1117,7 @@ packages:
z-schema: 5.0.5 z-schema: 5.0.5
dev: true dev: true
/@rushstack/node-core-library/3.55.2_@types+node@18.15.2: /@rushstack/node-core-library/3.55.2_@types+node@18.15.3:
resolution: {integrity: sha512-SaLe/x/Q/uBVdNFK5V1xXvsVps0y7h1sN7aSJllQyFbugyOaxhNRF25bwEDnicARNEjJw0pk0lYnJQ9Kr6ev0A==} resolution: {integrity: sha512-SaLe/x/Q/uBVdNFK5V1xXvsVps0y7h1sN7aSJllQyFbugyOaxhNRF25bwEDnicARNEjJw0pk0lYnJQ9Kr6ev0A==}
peerDependencies: peerDependencies:
'@types/node': '*' '@types/node': '*'
...@@ -1125,7 +1125,7 @@ packages: ...@@ -1125,7 +1125,7 @@ packages:
'@types/node': '@types/node':
optional: true optional: true
dependencies: dependencies:
'@types/node': 18.15.2 '@types/node': 18.15.3
colors: 1.2.5 colors: 1.2.5
fs-extra: 7.0.1 fs-extra: 7.0.1
import-lazy: 4.0.0 import-lazy: 4.0.0
...@@ -1268,16 +1268,16 @@ packages: ...@@ -1268,16 +1268,16 @@ packages:
resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==} resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==}
dev: true dev: true
/@types/node/18.15.2: /@types/node/18.15.3:
resolution: {integrity: sha512-sDPHm2wfx2QhrMDK0pOt2J4KLJMAcerqWNvnED0itPRJWvI+bK+uNHzcH1dFsBlf7G3u8tqXmRF3wkvL9yUwMw==} resolution: {integrity: sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==}
dev: true dev: true
/@wesbos/code-icons/1.2.4: /@wesbos/code-icons/1.2.4:
resolution: {integrity: sha512-ZiU0xf7epnCRrLDQIPnFstzoNWDvcUTtKoDU3VhpjsaGRzVClSmsi39c4kHxIOdfxvg4zwdW+goH96xr/vMTQQ==} resolution: {integrity: sha512-ZiU0xf7epnCRrLDQIPnFstzoNWDvcUTtKoDU3VhpjsaGRzVClSmsi39c4kHxIOdfxvg4zwdW+goH96xr/vMTQQ==}
dependencies: dependencies:
'@types/node': 18.15.2 '@types/node': 18.15.3
vite: 4.1.4_@types+node@18.15.2 vite: 4.1.4_@types+node@18.15.3
vite-plugin-dts: 1.7.3_qtt2czb2qoqfpedyqirhvl644q vite-plugin-dts: 1.7.3_fiacabm3igr2j6cgupjjtacm3i
vscode-icons-js: 11.6.1 vscode-icons-js: 11.6.1
transitivePeerDependencies: transitivePeerDependencies:
- less - less
...@@ -1423,7 +1423,7 @@ packages: ...@@ -1423,7 +1423,7 @@ packages:
postcss: ^8.1.0 postcss: ^8.1.0
dependencies: dependencies:
browserslist: 4.21.5 browserslist: 4.21.5
caniuse-lite: 1.0.30001465 caniuse-lite: 1.0.30001466
fraction.js: 4.2.0 fraction.js: 4.2.0
normalize-range: 0.1.2 normalize-range: 0.1.2
picocolors: 1.0.0 picocolors: 1.0.0
...@@ -1500,7 +1500,7 @@ packages: ...@@ -1500,7 +1500,7 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true hasBin: true
dependencies: dependencies:
caniuse-lite: 1.0.30001465 caniuse-lite: 1.0.30001466
electron-to-chromium: 1.4.328 electron-to-chromium: 1.4.328
node-releases: 2.0.10 node-releases: 2.0.10
update-browserslist-db: 1.0.10_browserslist@4.21.5 update-browserslist-db: 1.0.10_browserslist@4.21.5
...@@ -1575,13 +1575,13 @@ packages: ...@@ -1575,13 +1575,13 @@ packages:
resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==} resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==}
dependencies: dependencies:
browserslist: 4.21.5 browserslist: 4.21.5
caniuse-lite: 1.0.30001465 caniuse-lite: 1.0.30001466
lodash.memoize: 4.1.2 lodash.memoize: 4.1.2
lodash.uniq: 4.5.0 lodash.uniq: 4.5.0
dev: true dev: true
/caniuse-lite/1.0.30001465: /caniuse-lite/1.0.30001466:
resolution: {integrity: sha512-HvjgL3MYAJjceTDCcjRnQGjwUz/5qec9n7JPOzUursUoOTIsYCSDOb1l7RsnZE8mjbxG78zVRCKfrBXyvChBag==} resolution: {integrity: sha512-ewtFBSfWjEmxUgNBSZItFSmVtvk9zkwkl1OfRZlKA8slltRN+/C/tuGVrF9styXkN36Yu3+SeJ1qkXxDEyNZ5w==}
dev: true dev: true
/catharsis/0.9.0: /catharsis/0.9.0:
...@@ -4728,21 +4728,21 @@ packages: ...@@ -4728,21 +4728,21 @@ packages:
resolution: {integrity: sha512-g0cm0wbrR6b6wR8FWtfD1RSDPacdumKEOAnneXv+NpJ9ez+j6rklRv6lMOO+aPf+Y6Zb8OzgIk0FXBZ6h+DeZQ==} resolution: {integrity: sha512-g0cm0wbrR6b6wR8FWtfD1RSDPacdumKEOAnneXv+NpJ9ez+j6rklRv6lMOO+aPf+Y6Zb8OzgIk0FXBZ6h+DeZQ==}
dev: true dev: true
/vite-plugin-dts/1.7.3_qtt2czb2qoqfpedyqirhvl644q: /vite-plugin-dts/1.7.3_fiacabm3igr2j6cgupjjtacm3i:
resolution: {integrity: sha512-u3t45p6fTbzUPMkwYe0ESwuUeiRMlwdPfD3dRyDKUwLe2WmEYcFyVp2o9/ke2EMrM51lQcmNWdV9eLcgjD1/ng==} resolution: {integrity: sha512-u3t45p6fTbzUPMkwYe0ESwuUeiRMlwdPfD3dRyDKUwLe2WmEYcFyVp2o9/ke2EMrM51lQcmNWdV9eLcgjD1/ng==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies: peerDependencies:
vite: '>=2.9.0' vite: '>=2.9.0'
dependencies: dependencies:
'@microsoft/api-extractor': 7.34.4_@types+node@18.15.2 '@microsoft/api-extractor': 7.34.4_@types+node@18.15.3
'@rollup/pluginutils': 5.0.2 '@rollup/pluginutils': 5.0.2
'@rushstack/node-core-library': 3.55.2_@types+node@18.15.2 '@rushstack/node-core-library': 3.55.2_@types+node@18.15.3
debug: 4.3.4 debug: 4.3.4
fast-glob: 3.2.12 fast-glob: 3.2.12
fs-extra: 10.1.0 fs-extra: 10.1.0
kolorist: 1.7.0 kolorist: 1.7.0
ts-morph: 17.0.1 ts-morph: 17.0.1
vite: 4.1.4_@types+node@18.15.2 vite: 4.1.4_@types+node@18.15.3
transitivePeerDependencies: transitivePeerDependencies:
- '@types/node' - '@types/node'
- rollup - rollup
...@@ -4846,7 +4846,7 @@ packages: ...@@ -4846,7 +4846,7 @@ packages:
fsevents: 2.3.2 fsevents: 2.3.2
dev: true dev: true
/vite/4.1.4_@types+node@18.15.2: /vite/4.1.4_@types+node@18.15.3:
resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==} resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true hasBin: true
...@@ -4871,7 +4871,7 @@ packages: ...@@ -4871,7 +4871,7 @@ packages:
terser: terser:
optional: true optional: true
dependencies: dependencies:
'@types/node': 18.15.2 '@types/node': 18.15.3
esbuild: 0.16.17 esbuild: 0.16.17
postcss: 8.4.21 postcss: 8.4.21
resolve: 1.22.1 resolve: 1.22.1
......
...@@ -7,7 +7,7 @@ describe('Monster', function () { ...@@ -7,7 +7,7 @@ describe('Monster', function () {
let monsterVersion let monsterVersion
/** don´t touch, replaced by make with package.json version */ /** don´t touch, replaced by make with package.json version */
monsterVersion = new Version("3.26.0") monsterVersion = new Version("3.27.0")
let m = getMonsterVersion(); let m = getMonsterVersion();
......
{"version":"3.27.0"} {"version":"3.28.0"}