Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Finnish language and tiny size setting #32

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions MMM-text-clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand All @@ -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';
}
Expand Down Expand Up @@ -166,7 +166,6 @@ Module.register('MMM-text-clock', {
}
return value;
});

if (this.identifier !== revivedPayload.id) {
return;
}
Expand All @@ -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(() => {
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Supported languages:
- English
- Spanish
- Dutch
- Finnish
- French
- Japanese
- Italian
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions css/MMM-text-clock.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
display: grid;
}

.grid--gap-xsmall {
grid-gap: 0.20rem 0.35rem;
}

.grid--gap-small {
grid-gap: 0.75rem 1.125rem;
}
Expand Down
36 changes: 36 additions & 0 deletions locale/fi/getActiveWords.js
Original file line number Diff line number Diff line change
@@ -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;
};
1 change: 1 addition & 0 deletions locale/fi/gridColumns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 14;
11 changes: 11 additions & 0 deletions locale/fi/index.js
Original file line number Diff line number Diff line change
@@ -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,
};
12 changes: 12 additions & 0 deletions locale/fi/letters.js
Original file line number Diff line number Diff line change
@@ -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',
];
26 changes: 26 additions & 0 deletions locale/fi/wordMap.js
Original file line number Diff line number Diff line change
@@ -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]
};
3 changes: 2 additions & 1 deletion locale/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -12,7 +13,7 @@ module.exports = {
ch,
en,
es,
fr,
fi,
it,
jp,
nl,
Expand Down