diff --git a/MMM-text-clock.js b/MMM-text-clock.js index b3f628f..3050173 100644 --- a/MMM-text-clock.js +++ b/MMM-text-clock.js @@ -13,7 +13,7 @@ Module.register('MMM-text-clock', { fullscreen: false, }, - supportedLanguages: ['ar', 'ch', 'en', 'es', 'fr', 'it', 'jp', 'nl'], + supportedLanguages: ['ar', 'ch', 'en', 'es', 'fi', 'fr', 'it', 'jp', 'nl'], start: function () { Log.info(`Starting module: ${this.name}`); @@ -37,9 +37,9 @@ Module.register('MMM-text-clock', { /* * Validate size config */ - if (!['small', 'medium', 'large'].includes(this.size)) { + if (!['xsmall', 'small', 'medium', 'large'].includes(this.size)) { Log.error( - `size: "${this.size}" is not a supported value. Please use "small", "medium" or "large". Falling back to "medium".` + `size: "${this.size}" is not a supported value. Please use "xsmall", "small", "medium" or "large". Falling back to "medium".` ); this.size = 'medium'; } @@ -166,7 +166,6 @@ Module.register('MMM-text-clock', { } return value; }); - if (this.identifier !== revivedPayload.id) { return; } @@ -179,7 +178,6 @@ Module.register('MMM-text-clock', { this.words = revivedPayload.words; this.wordMap = revivedPayload.wordMap; this.currentLanguage = revivedPayload.language; - this.updateDom(); this.updateInterval = setInterval(() => { @@ -202,6 +200,10 @@ Module.register('MMM-text-clock', { grid.style.gridTemplateColumns = `repeat(${this.gridColumns}, 1fr)`; switch (this.size) { + case 'xsmall': { + grid.classList.add('grid--gap-xsmall'); + break; + } case 'small': { grid.classList.add('grid--gap-small'); break; diff --git a/README.md b/README.md index 00ff13b..b919091 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Supported languages: - English - Spanish - Dutch +- Finnish - French - Japanese - Italian @@ -68,8 +69,8 @@ The following configurations are available: Config | Type | Default value | Description :-----------------------------|:-----------------------------------------------|:---------------|:------------ `compact` | `boolean` | `false` | Compact mode only shows highlighted letters -`size` | `small \| medium \| large` | `medium` | The size of the clock -`language` | `ar \| ch \| en \| es \| fr \| it \| jp \| nl` | `en` | A language or list of languages to alternate through. Overrides config language. +`size` | `xsmall \| small \| medium \| large` | `medium` | The size of the clock +`language` | `ar \| ch \| en \| es \| fi \| fr \| it \| jp \| nl` | `en` | A language or list of languages to alternate through. Overrides config language. `languageAlternationInterval` | `number` | `60` | Interval in minutes at which the language changes (> 0) `fullscreen` | `boolean` | `false` | Fullscreen mode takes over your entire screen diff --git a/css/MMM-text-clock.css b/css/MMM-text-clock.css index 712926b..2cd02f7 100644 --- a/css/MMM-text-clock.css +++ b/css/MMM-text-clock.css @@ -22,6 +22,10 @@ display: grid; } +.grid--gap-xsmall { + grid-gap: 0.20rem 0.35rem; +} + .grid--gap-small { grid-gap: 0.75rem 1.125rem; } diff --git a/locale/fi/getActiveWords.js b/locale/fi/getActiveWords.js new file mode 100644 index 0000000..e2593c4 --- /dev/null +++ b/locale/fi/getActiveWords.js @@ -0,0 +1,36 @@ +module.exports = function (time) { + const wordIndexes = []; + const display = this.displayTime(time); + wordIndexes.push(this.wordMap.time); + wordIndexes.push(this.wordMap.is); + + if (Math.abs(display.minutes_to_display) === 5) { + wordIndexes.push(this.wordMap.five); + } else if (Math.abs(display.minutes_to_display) === 10) { + wordIndexes.push(this.wordMap.ten); + } else if (Math.abs(display.minutes_to_display) === 15) { + wordIndexes.push(this.wordMap.quarter); + } else if (Math.abs(display.minutes_to_display) === 20) { + wordIndexes.push(this.wordMap.twenty); + } else if (Math.abs(display.minutes_to_display) === 25) { + wordIndexes.push(this.wordMap.twentyfive); + } else if (display.minutes_to_display === 30) { + wordIndexes.push(this.wordMap.half); + display.hours_to_display = (display.hours_to_display + 1) % 12; + } + + if (display.minutes_to_display !== 30) { + if (display.minutes_to_display > 0) { + wordIndexes.push(this.wordMap.past); + } else if (display.minutes_to_display < 0) { + wordIndexes.push(this.wordMap.to); + } + } + + wordIndexes.push(this.wordMap[display.hours_to_display]); + + if (display.minutes_to_display === 0) { + wordIndexes.push(this.wordMap.zero); + } + return wordIndexes; +}; diff --git a/locale/fi/gridColumns.js b/locale/fi/gridColumns.js new file mode 100644 index 0000000..de4e38f --- /dev/null +++ b/locale/fi/gridColumns.js @@ -0,0 +1 @@ +module.exports = 14; diff --git a/locale/fi/index.js b/locale/fi/index.js new file mode 100644 index 0000000..436b74f --- /dev/null +++ b/locale/fi/index.js @@ -0,0 +1,11 @@ +const getActiveWords = require('./getActiveWords'); +const gridColumns = require('./gridColumns'); +const letters = require('./letters'); +const wordMap = require('./wordMap'); + +module.exports = { + getActiveWords, + gridColumns, + letters, + wordMap, +}; diff --git a/locale/fi/letters.js b/locale/fi/letters.js new file mode 100644 index 0000000..eba8341 --- /dev/null +++ b/locale/fi/letters.js @@ -0,0 +1,12 @@ +module.exports = [ + 'k', 'e', 'l', 'l', 'o', 'm', 'o', 'n', 'a', 'p', 'u', 'o', 'l', 'i', + 'k', 'a', 'h', 't', 'a', 'k', 'y', 'm', 'm', 'e', 'n', 't', 'ä', '-', + 'v', 'i', 'i', 't', 't', 'ä', 'e', 'v', 'a', 'r', 't', 't', 'i', 'a', + 't', 'a', 's', 'a', 'n', 'y', 'l', 'i', 'v', 'a', 'i', 'l', 'l', 'e', + 'k', 'o', 'l', 'm', 'e', 's', 'e', 'i', 't', 's', 'e', 'm', 'ä', 'n', + 'n', 'e', 'l', 'j', 'ä', 'k', 'a', 'h', 'd', 'e', 'k', 's', 'a', 'n', + 'v', 'i', 'i', 's', 'i', 'y', 'h', 'd', 'e', 'k', 's', 'ä', 'n', 'a', + 'k', 'u', 'u', 's', 'i', 'k', 'y', 'm', 'm', 'e', 'n', 'e', 'n', 'i', + 'y', 'k', 's', 'i', 't', 'o', 'i', 's', 't', 'a', 'a', 'h', 'j', 'l', + 'k', 'a', 'k', 's', 'i', 't', 'o', 'i', 's', 't', 'a', 'n', 'e', 't', +]; diff --git a/locale/fi/wordMap.js b/locale/fi/wordMap.js new file mode 100644 index 0000000..1cf15bd --- /dev/null +++ b/locale/fi/wordMap.js @@ -0,0 +1,26 @@ +module.exports = { + time: [0, 1, 2, 3, 4], + is: [6, 7], + quarter: [35, 36, 37, 38, 39, 40, 41], + twenty: [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], + five: [28, 29, 30, 31, 32, 33], + twentyfive: [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], + half: [9, 10, 11, 12, 13], + ten: [19, 20, 21, 22, 23, 24, 25, 26], + zero: [42, 43, 44, 45, 46], + past: [47, 48, 49], + to: [50, 51, 52, 53, 54, 55], + 0: [126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136], + 1: [112, 113, 114, 115], + 2: [126, 127, 128, 129, 130], + 3: [56, 57, 58, 59, 60], + 4: [70, 71, 72, 73, 74], + 5: [84, 85, 86, 87, 88], + 6: [98, 99, 100, 101, 102], + 7: [61, 62, 63, 64, 65, 66, 67, 68, 69], + 8: [75, 76, 77, 78, 79, 80, 81, 82, 83], + 9: [89, 90, 91, 92, 93, 94, 95, 96], + 10: [103, 104, 105, 106, 107, 108, 109, 110], + 11: [112, 113, 114, 115, 116, 117, 118, 119, 120, 121], + 12: [126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136] +}; diff --git a/locale/index.js b/locale/index.js index cdff030..025cf74 100644 --- a/locale/index.js +++ b/locale/index.js @@ -2,6 +2,7 @@ const ar = require('./ar'); const ch = require('./ch'); const en = require('./en'); const es = require('./es'); +const fi = require('./fi'); const fr = require('./fr'); const it = require('./it'); const jp = require('./jp'); @@ -12,7 +13,7 @@ module.exports = { ch, en, es, - fr, + fi, it, jp, nl,