Skip to content

lightweight, client-only calendar web application. All data persists in the URL hash for instant sharing, No backend required. Optional AES-GCM password protection keeps shared links locked without a server

JavaScript

feat: Add countdown widget, focus mode, and internationalization support with new calendar and agenda rendering modules.

Supun Lakmalf3543b50f68d
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..e07d940
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "i18next.i18nPaths": "c:/Users/hp/Documents/GitHub/hash/hash-calendar/locales",
+ "liveServer.settings.port": 5501
+}
diff --git a/index.html b/index.html
index ba41cda..da2e265 100644
--- a/index.html
+++ b/index.html
@@ -47,6 +47,8 @@
rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<link rel="stylesheet" href="styles.css">
+ <link rel="stylesheet" href="styles-i18n.css">
+ <link rel="stylesheet" href="styles-logo.css">
<script type="application/ld+json">
{
"@context": "https://schema.org",
@@ -63,19 +65,14 @@
</head>
<body>
- <div id="mobile-warning" class="mobile-warning hidden" role="status" aria-live="polite">
- <div class="mobile-warning-card">
- <div class="mobile-warning-copy">
- <span class="mobile-warning-title">Mobile view notice</span>
- <span class="mobile-warning-text">This app isn't optimized for mobile and tab view yet.</span>
- </div>
- <button id="mobile-warning-dismiss" type="button" class="ghost">Got it</button>
- </div>
- </div>
<div class="app">
<header class="topbar">
<div class="brand">
- <div class="brand-mark">#</div>
+ <a href="/" class="logo-link">
+ <div class="brand-mark">
+ <img src="logo.png" alt="hash-calendar logo" class="logo-img">
+ </div>
+ </a>
<div class="brand-text">
<input id="calendar-title" class="title-input" type="text" maxlength="60" value="hash-calendar"
aria-label="Calendar title">
@@ -84,9 +81,11 @@
</div>
<div class="top-actions">
<div class="nav-group">
- <button id="prev-month" type="button" aria-label="Previous month">Prev</button>
- <button id="today-btn" type="button">Today</button>
- <button id="next-month" type="button" aria-label="Next month">Next</button>
+ <button id="prev-month" type="button" aria-label="Previous month" data-i18n-aria-label="nav.prevMonth"
+ data-i18n="nav.prev">Prev</button>
+ <button id="today-btn" type="button" data-i18n="nav.today">Today</button>
+ <button id="next-month" type="button" aria-label="Next month" data-i18n-aria-label="nav.nextMonth"
+ data-i18n="nav.next">Next</button>
</div>
<div id="mobile-menu-toggle" class="mobile-only">
@@ -97,27 +96,30 @@
<div id="secondary-actions" class="secondary-actions">
<div class="view-toggle" role="tablist">
- <button data-view="day" role="tab" aria-selected="false">Day</button>
- <button data-view="week" role="tab" aria-selected="false">Week</button>
- <button data-view="month" role="tab" aria-selected="true" class="active">Month</button>
- <button data-view="year" role="tab" aria-selected="false">Year</button>
- <button data-view="agenda" role="tab" aria-selected="false">Agenda</button>
+ <button data-view="day" role="tab" aria-selected="false" data-i18n="view.day">Day</button>
+ <button data-view="week" role="tab" aria-selected="false" data-i18n="view.week">Week</button>
+ <button data-view="month" role="tab" aria-selected="true" class="active"
+ data-i18n="view.month">Month</button>
+ <button data-view="year" role="tab" aria-selected="false" data-i18n="view.year">Year</button>
+ <button data-view="agenda" role="tab" aria-selected="false" data-i18n="view.agenda">Agenda</button>
</div>
- <button id="focus-btn" type="button">Focus</button>
+ <button id="focus-btn" type="button" data-i18n="btn.focus">Focus</button>
<div class="action-divider desktop-only"></div>
- <button id="add-event" class="primary" type="button">Add event</button>
- <button id="copy-link" type="button">Copy link</button>
- <button id="share-qr" type="button">Share QR</button>
- <button id="lock-btn" type="button">Lock</button>
- <button id="world-planner-btn" type="button" class="accent-btn" aria-label="Open World Planner">
- <i class="fa-solid fa-earth-americas"></i> Planner
+ <button id="add-event" class="primary" type="button" data-i18n="btn.addEvent">Add event</button>
+ <button id="copy-link" type="button" data-i18n="btn.copyLink">Copy link</button>
+ <button id="share-qr" type="button" data-i18n="btn.shareQr">Share QR</button>
+ <button id="lock-btn" type="button" data-i18n="btn.lock">Lock</button>
+ <button id="world-planner-btn" type="button" class="accent-btn" aria-label="Open World Planner"
+ data-i18n-aria-label="btn.worldPlanner">
+ <i class="fa-solid fa-earth-americas"></i> <span data-i18n="btn.worldPlanner">Planner</span>
</button>
<!-- App Launcher -->
<div class="app-launcher-container">
- <button id="app-launcher-btn" type="button" class="icon-btn" aria-label="Google Apps" aria-expanded="false">
+ <button id="app-launcher-btn" type="button" class="icon-btn" aria-label="App Launcher"
+ data-i18n-aria-label="launcher.ariaLabel" aria-expanded="false">
<i class="fa-solid fa-grip"></i>
</button>
<div id="app-launcher-menu" class="app-launcher-menu hidden">
@@ -135,7 +137,7 @@
</header>
<div id="countdown-widget" class="countdown-container hidden" aria-live="polite">
- <div class="countdown-label">Up Next</div>
+ <div class="countdown-label" data-i18n="countdown.upNext">Up Next</div>
<div class="countdown-content">
<div id="nextEventTitle" class="countdown-title">--</div>
<div id="countdownTimer" class="countdown-timer">00:00:00</div>
@@ -151,10 +153,24 @@
<div class="panel-actions">
<button id="mobile-sidebar-toggle" class="mobile-only" type="button">
<i class="fa-solid fa-list-ul"></i>
- <span>Details</span>
+ <span data-i18n="label.details">Details</span>
</button>
- <button id="weekstart-toggle" type="button">Week starts Sunday</button>
- <button id="theme-toggle" type="button">Theme: Light</button>
+ <button id="weekstart-toggle" type="button" data-i18n="settings.weekStartsSunday">Week starts
+ Sunday</button>
+ <button id="theme-toggle" type="button" data-i18n="settings.themeLight">Theme: Light</button>
+ <div class="dropdown-container lang-selector">
+ <button id="language-btn" class="dropdown-trigger" type="button" aria-haspopup="listbox"
+ aria-expanded="false">
+ <i class="fa-solid fa-language"></i>
+ <span id="current-lang">English</span>
+ <i class="fa-solid fa-chevron-down"></i>
+ </button>
+ <div id="language-dropdown" class="dropdown-menu hidden">
+ <ul id="language-list" class="dropdown-list" role="listbox">
+ <!-- Generated by JS -->
+ </ul>
+ </div>
+ </div>
</div>
</div>
</div>
@@ -162,9 +178,9 @@
<div id="calendar-grid" class="calendar-grid" role="grid" aria-label="Calendar"></div>
<div id="locked-overlay" class="locked-overlay hidden">
<div class="locked-card">
- <h3>Encrypted calendar</h3>
- <p>Enter the password to unlock and edit this calendar.</p>
- <button id="unlock-btn" type="button" class="primary">Unlock</button>
+ <h3 data-i18n="locked.title">Encrypted calendar</h3>
+ <p data-i18n="locked.message">Enter the password to unlock and edit this calendar.</p>
+ <button id="unlock-btn" type="button" class="primary" data-i18n="btn.unlock">Unlock</button>
</div>
</div>
</section>
@@ -174,29 +190,30 @@
<i class="fa-solid fa-xmark"></i>
</button>
<div class="side-card">
- <h3 id="selected-date-label" class="side-title">Selected day</h3>
+ <h3 id="selected-date-label" class="side-title" data-i18n="panel.selectedDay">Selected day</h3>
<div id="event-list" class="event-list"></div>
- <button id="add-event-inline" type="button" class="ghost">Add event for this day</button>
+ <button id="add-event-inline" type="button" class="ghost" data-i18n="btn.addEventForDay">Add event for this
+ day</button>
</div>
<div class="side-card">
- <h4 class="side-title">Share and export</h4>
+ <h4 class="side-title" data-i18n="panel.shareExport">Share and export</h4>
<div class="status-row">
- <span>URL length</span>
+ <span data-i18n="panel.urlLength">URL length</span>
<strong id="url-length">0</strong>
</div>
<p id="url-warning" class="url-warning"></p>
<div class="stacked-actions">
- <button id="view-json" type="button" class="ghost">View JSON</button>
- <button id="export-json" type="button" class="ghost">Export JSON</button>
- <button id="import-ics" type="button" class="ghost">Import .ics</button>
+ <button id="view-json" type="button" class="ghost" data-i18n="btn.viewJson">View JSON</button>
+ <button id="export-json" type="button" class="ghost" data-i18n="btn.exportJson">Export JSON</button>
+ <button id="import-ics" type="button" class="ghost" data-i18n="btn.importIcs">Import .ics</button>
<input id="ics-input" type="file" accept=".ics,text/calendar" hidden>
</div>
</div>
<div class="side-card danger">
- <h4 class="side-title">Danger zone</h4>
- <button id="clear-all" type="button" class="danger-btn">Clear calendar</button>
+ <h4 class="side-title" data-i18n="panel.dangerZone">Danger zone</h4>
+ <button id="clear-all" type="button" class="danger-btn" data-i18n="btn.clearCalendar">Clear calendar</button>
</div>
</aside>
@@ -206,10 +223,11 @@
</button>
<div class="tz-header">
<div>
- <h4 class="tz-title">World Clock</h4>
- <p class="tz-subtitle">Local time plus saved zones</p>
+ <h4 class="tz-title" data-i18n="tz.worldClock">World Clock</h4>
+ <p class="tz-subtitle" data-i18n="tz.subtitle">Local time plus saved zones</p>
</div>
- <button id="add-tz-btn" type="button" class="icon-btn tz-add" aria-label="Add timezone">+</button>
+ <button id="add-tz-btn" type="button" class="icon-btn tz-add" aria-label="Add timezone"
+ data-i18n-aria-label="btn.addTimezone">+</button>
</div>
<div id="tz-list" class="tz-list" aria-live="polite"></div>
</aside>
@@ -223,15 +241,15 @@
<div id="focus-clock" class="focus-clock">00:00</div>
</div>
<div class="focus-main">
- <div id="focus-status" class="focus-status">NEXT UP IN</div>
+ <div id="focus-status" class="focus-status" data-i18n="focus.nextUpIn">NEXT UP IN</div>
<div id="focus-timer" class="focus-timer">00:00:00</div>
<div class="focus-event">
- <div id="focus-title" class="focus-title">No upcoming events</div>
+ <div id="focus-title" class="focus-title" data-i18n="focus.noUpcoming">No upcoming events</div>
<div id="focus-time" class="focus-time"></div>
</div>
</div>
<div id="focus-upnext" class="focus-upnext hidden">
- <div class="focus-upnext-label">Up later</div>
+ <div class="focus-upnext-label" data-i18n="focus.upLater">Up later</div>
<ul id="focus-upnext-list" class="focus-upnext-list"></ul>
</div>
</div>
@@ -241,54 +259,55 @@
<div class="modal-backdrop"></div>
<div class="modal-card">
<header class="modal-header">
- <h3 id="event-modal-title">Add event</h3>
- <button id="event-close" type="button" class="icon-btn" aria-label="Close">x</button>
+ <h3 id="event-modal-title" data-i18n="modal.addEvent">Add event</h3>
+ <button id="event-close" type="button" class="icon-btn" aria-label="Close"
+ data-i18n-aria-label="label.close">x</button>
</header>
<form id="event-form" class="modal-form">
<label class="field">
- <span>Title</span>
+ <span data-i18n="event.title">Title</span>
<input id="event-title" type="text" maxlength="80" required>
</label>
<div class="field-row">
<label class="field">
- <span>Date</span>
+ <span data-i18n="event.date">Date</span>
<input id="event-date" type="date" required>
</label>
<label class="field">
- <span>Start</span>
+ <span data-i18n="event.start">Start</span>
<input id="event-time" type="time">
</label>
</div>
<div class="field-row">
<label class="field">
- <span>Duration (mins)</span>
+ <span data-i18n="event.duration">Duration (mins)</span>
<input id="event-duration" type="number" min="0" step="5" value="60">
</label>
<label class="field checkbox-field">
<input id="event-all-day" type="checkbox">
- <span>All day</span>
+ <span data-i18n="event.allDay">All day</span>
</label>
</div>
<label class="field">
- <span>Recurrence</span>
+ <span data-i18n="event.recurrence">Recurrence</span>
<select id="event-recurrence">
- <option value="">None</option>
- <option value="d">Daily</option>
- <option value="w">Weekly</option>
- <option value="m">Monthly</option>
- <option value="y">Yearly</option>
+ <option value="" data-i18n="recurrence.none">None</option>
+ <option value="d" data-i18n="recurrence.daily">Daily</option>
+ <option value="w" data-i18n="recurrence.weekly">Weekly</option>
+ <option value="m" data-i18n="recurrence.monthly">Monthly</option>
+ <option value="y" data-i18n="recurrence.yearly">Yearly</option>
</select>
</label>
<label class="field">
- <span>Color</span>
+ <span data-i18n="event.color">Color</span>
<input id="event-color" type="color" value="#ff6b6b">
</label>
<div id="color-palette" class="color-palette"></div>
<div class="modal-actions">
- <button id="event-delete" type="button" class="ghost danger hidden">Delete</button>
+ <button id="event-delete" type="button" class="ghost danger hidden" data-i18n="btn.delete">Delete</button>
<div class="modal-actions-right">
- <button id="event-cancel" type="button" class="ghost">Cancel</button>
- <button id="event-save" type="submit" class="primary">Save</button>
+ <button id="event-cancel" type="button" class="ghost" data-i18n="btn.cancel">Cancel</button>
+ <button id="event-save" type="submit" class="primary" data-i18n="btn.save">Save</button>
</div>
</div>
</form>
@@ -299,23 +318,24 @@
<div class="modal-backdrop"></div>
<div class="modal-card">
<header class="modal-header">
- <h3 id="password-title">Unlock calendar</h3>
- <button id="password-close" type="button" class="icon-btn" aria-label="Close">x</button>
+ <h3 id="password-title" data-i18n="modal.unlockCalendar">Unlock calendar</h3>
+ <button id="password-close" type="button" class="icon-btn" aria-label="Close"
+ data-i18n-aria-label="label.close">x</button>
</header>
<div class="modal-form">
<p id="password-desc" class="modal-note"></p>
<label class="field">
- <span>Password</span>
+ <span data-i18n="password.password">Password</span>
<input id="password-input" type="password" autocomplete="new-password">
</label>
<label id="password-confirm-field" class="field hidden">
- <span>Confirm password</span>
+ <span data-i18n="password.confirmPassword">Confirm password</span>
<input id="password-confirm" type="password" autocomplete="new-password">
</label>
<p id="password-error" class="modal-error hidden"></p>
<div class="modal-actions">
- <button id="password-cancel" type="button" class="ghost">Cancel</button>
- <button id="password-submit" type="button" class="primary">Unlock</button>
+ <button id="password-cancel" type="button" class="ghost" data-i18n="btn.cancel">Cancel</button>
+ <button id="password-submit" type="button" class="primary" data-i18n="btn.unlock">Unlock</button>
</div>
</div>
</div>
@@ -325,23 +345,24 @@
<div class="modal-backdrop"></div>
<div class="modal-card json-modal-card">
<header class="modal-header">
- <h3 id="json-modal-title">Share data</h3>
- <button id="json-close" type="button" class="icon-btn" aria-label="Close">x</button>
+ <h3 id="json-modal-title" data-i18n="modal.shareData">Share data</h3>
+ <button id="json-close" type="button" class="icon-btn" aria-label="Close"
+ data-i18n-aria-label="label.close">x</button>
</header>
<div class="modal-form">
<label class="field">
- <span>URL hash</span>
+ <span data-i18n="json.urlHash">URL hash</span>
<input id="json-hash" type="text" readonly>
</label>
<label class="field">
- <span>JSON data</span>
+ <span data-i18n="json.jsonData">JSON data</span>
<textarea id="json-output" class="json-output" rows="10" readonly></textarea>
</label>
<div class="modal-actions">
- <button id="json-copy-hash" type="button" class="ghost">Copy hash</button>
+ <button id="json-copy-hash" type="button" class="ghost" data-i18n="btn.copyHash">Copy hash</button>
<div class="modal-actions-right">
- <button id="json-copy" type="button" class="ghost">Copy JSON</button>
- <button id="json-download" type="button" class="primary">Download JSON</button>
+ <button id="json-copy" type="button" class="ghost" data-i18n="btn.copyJson">Copy JSON</button>
+ <button id="json-download" type="button" class="primary" data-i18n="btn.downloadJson">Download JSON</button>
</div>
</div>
</div>
@@ -352,16 +373,18 @@
<div class="modal-backdrop"></div>
<div class="modal-card qr-modal-card">
<header class="modal-header">
- <h3 id="qr-modal-title">Scan to open on mobile</h3>
- <button id="qr-close" type="button" class="icon-btn" aria-label="Close">x</button>
+ <h3 id="qr-modal-title" data-i18n="modal.scanQr">Scan to open on mobile</h3>
+ <button id="qr-close" type="button" class="icon-btn" aria-label="Close"
+ data-i18n-aria-label="label.close">x</button>
</header>
<div class="qr-modal-body">
<p id="qr-warning" class="qr-warning hidden"></p>
<div id="qrcode-container" class="qr-code"></div>
- <p class="qr-helper">Point your phone camera at this code to open your calendar.</p>
+ <p class="qr-helper" data-i18n="qr.helper">Point your phone camera at this code to open your calendar.</p>
</div>
<div class="modal-actions qr-modal-actions">
- <button id="qr-copy-link" type="button" class="ghost">Copy text link instead</button>
+ <button id="qr-copy-link" type="button" class="ghost" data-i18n="btn.copyTextLink">Copy text link
+ instead</button>
</div>
</div>
</div>
@@ -369,15 +392,18 @@
<dialog id="tz-modal" class="tz-modal" aria-labelledby="tz-modal-title">
<div class="tz-modal-card">
<header class="tz-modal-header">
- <h3 id="tz-modal-title">Select timezone</h3>
- <button id="close-tz-modal" type="button" class="icon-btn" aria-label="Close">x</button>
+ <h3 id="tz-modal-title" data-i18n="modal.selectTimezone">Select timezone</h3>
+ <button id="close-tz-modal" type="button" class="icon-btn" aria-label="Close"
+ data-i18n-aria-label="label.close">x</button>
</header>
<label class="field">
- <span>Search</span>
- <input type="text" id="tz-search" placeholder="Search (e.g. London)" autocomplete="off">
+ <span data-i18n="tz.search">Search</span>
+ <input type="text" id="tz-search" placeholder="Search (e.g. London)"
+ data-i18n-placeholder="tz.searchPlaceholder" autocomplete="off">
</label>
<ul id="tz-results" class="tz-results" role="listbox"></ul>
- <p id="tz-empty" class="tz-empty hidden">No matches yet. Try a city, region, or UTC+5:30.</p>
+ <p id="tz-empty" class="tz-empty hidden" data-i18n="tz.noMatches">No matches yet. Try a city, region, or UTC+5:30.
+ </p>
</div>
</dialog>
@@ -386,10 +412,11 @@
<div class="planner-modal-card">
<header class="planner-header">
<div class="planner-controls-left">
- <h3 id="wp-modal-title" class="hidden">World Planner</h3>
+ <h3 id="wp-modal-title" class="hidden" data-i18n="modal.worldPlanner">World Planner</h3>
<div class="wp-search-wrapper">
<i class="fa-solid fa-earth-americas wp-search-icon"></i>
- <input id="wp-add-zone" type="text" placeholder="Add timezone (e.g. London)" autocomplete="off">
+ <input id="wp-add-zone" type="text" placeholder="Add timezone (e.g. London)"
+ data-i18n-placeholder="planner.addTimezone" autocomplete="off">
<ul id="wp-tz-results" class="tz-results hidden" role="listbox"></ul>
</div>
</div>
diff --git a/locales/en.js b/locales/en.js
new file mode 100644
index 0000000..39c1269
--- /dev/null
+++ b/locales/en.js
@@ -0,0 +1,238 @@
+export default {
+ // Navigation
+ 'nav.prev': 'Prev',
+ 'nav.today': 'Today',
+ 'nav.next': 'Next',
+ 'nav.prevMonth': 'Previous month',
+ 'nav.nextMonth': 'Next month',
+
+ // View toggles
+ 'view.day': 'Day',
+ 'view.week': 'Week',
+ 'view.month': 'Month',
+ 'view.year': 'Year',
+ 'view.agenda': 'Agenda',
+
+ // Action buttons
+ 'btn.addEvent': 'Add event',
+ 'btn.copyLink': 'Copy link',
+ 'btn.shareQr': 'Share QR',
+ 'btn.lock': 'Lock',
+ 'btn.unlock': 'Unlock',
+ 'btn.removeLock': 'Remove lock',
+ 'btn.focus': 'Focus',
+ 'btn.exitFocus': 'Exit focus',
+ 'btn.save': 'Save',
+ 'btn.cancel': 'Cancel',
+ 'btn.delete': 'Delete',
+ 'btn.addEventForDay': 'Add event for this day',
+ 'btn.viewJson': 'View JSON',
+ 'btn.exportJson': 'Export JSON',
+ 'btn.importIcs': 'Import .ics',
+ 'btn.clearCalendar': 'Clear calendar',
+ 'btn.addTimezone': 'Add timezone',
+ 'btn.gotIt': 'Got it',
+ 'btn.copyJson': 'Copy JSON',
+ 'btn.copyHash': 'Copy hash',
+ 'btn.downloadJson': 'Download JSON',
+ 'btn.copyTextLink': 'Copy text link instead',
+ 'btn.worldPlanner': 'Planner',
+ 'planner.notFound': 'Timezone not found',
+ 'planner.homeTitle': 'Make Home',
+ 'planner.removeTitle': 'Remove',
+ 'launcher.ariaLabel': 'App Launcher',
+ 'app.calendar': 'Hash Calendar',
+ 'app.spreadsheet': 'Spreadsheet Live',
+
+ // Modal titles
+ 'modal.addEvent': 'Add event',
+ 'modal.editEvent': 'Edit event',
+ 'modal.unlockCalendar': 'Unlock calendar',
+ 'modal.setPassword': 'Set password',
+ 'modal.shareData': 'Share data',
+ 'modal.scanQr': 'Scan to open on mobile',
+ 'modal.selectTimezone': 'Select timezone',
+ 'modal.worldPlanner': 'World Planner',
+
+ // Event form fields
+ 'event.title': 'Title',
+ 'event.date': 'Date',
+ 'event.start': 'Start',
+ 'event.duration': 'Duration (mins)',
+ 'event.allDay': 'All day',
+ 'event.recurrence': 'Recurrence',
+ 'event.color': 'Color',
+
+ // Recurrence options
+ 'recurrence.none': 'None',
+ 'recurrence.daily': 'Daily',
+ 'recurrence.weekly': 'Weekly',
+ 'recurrence.monthly': 'Monthly',
+ 'recurrence.yearly': 'Yearly',
+
+ // Password form
+ 'password.password': 'Password',
+ 'password.confirmPassword': 'Confirm password',
+ 'password.setDesc': 'Add a password so only people with the link and password can read this calendar.',
+ 'password.unlockDesc': 'Enter the password to decrypt this calendar.',
+ 'password.required': 'Password is required.',
+ 'password.mismatch': 'Passwords do not match.',
+
+ // Side panel sections
+ 'panel.selectedDay': 'Selected day',
+ 'panel.shareExport': 'Share and export',
+ 'panel.dangerZone': 'Danger zone',
+ 'panel.urlLength': 'URL length',
+ 'panel.urlWarning': 'Warning: long URLs may get truncated when shared.',
+
+ // Timezone/world clock
+ 'tz.worldClock': 'World Clock',
+ 'tz.subtitle': 'Local time plus saved zones',
+ 'tz.search': 'Search',
+ 'tz.searchPlaceholder': 'Search (e.g. London)',
+ 'tz.noMatches': 'No matches yet. Try a city, region, or UTC+5:30.',
+ 'tz.addToCompare': 'Add a timezone to compare.',
+ 'tz.notSupported': "Timezone search isn't supported in this browser.",
+
+ // Focus mode
+ 'focus.nextUpIn': 'NEXT UP IN',
+ 'focus.allClear': 'ALL CLEAR',
+ 'focus.inProgress': 'IN PROGRESS',
+ 'focus.noUpcoming': 'No upcoming events',
+ 'focus.upLater': 'Up later',
+
+ // Calendar display
+ 'calendar.allDay': 'All day',
+ 'calendar.moreEvents': '+{{count}} more',
+ 'calendar.noUpcoming': 'No upcoming events',
+ 'calendar.noEvents': 'No events yet.',
+
+ // Settings
+ 'settings.weekStartsSunday': 'Week starts Sunday',
+ 'settings.weekStartsMonday': 'Week starts Monday',
+ 'settings.themeLight': 'Theme: Light',
+ 'settings.themeDark': 'Theme: Dark',
+ 'settings.language': 'Language',
+
+ // Language names
+ 'lang.en': 'English',
+ 'lang.si': 'සිංහල',
+
+ // Toast messages
+ 'toast.linkCopied': 'Link copied',
+ 'toast.eventsImported': 'Events imported',
+ 'toast.eventDeleted': 'Event deleted',
+ 'toast.eventsCleared': 'Events cleared',
+ 'toast.jsonCopied': 'JSON copied',
+ 'toast.hashCopied': 'Hash copied',
+ 'toast.lockRemoved': 'Lock removed',
+ 'toast.calendarLocked': 'Calendar locked',
+ 'toast.calendarUnlocked': 'Calendar unlocked',
+ 'toast.incorrectPassword': 'Incorrect password',
+ 'toast.unableToCopyLink': 'Unable to copy link',
+ 'toast.unableToCopyJson': 'Unable to copy JSON',
+ 'toast.unableToCopyHash': 'Unable to copy hash',
+ 'toast.noEventsFound': 'No events found',
+ 'toast.qrLibraryFailed': 'QR library failed to load',
+ 'toast.qrError': 'Error generating QR code',
+
+ // Confirmation dialogs
+ 'confirm.deleteEvent': 'Delete this event?',
+ 'confirm.clearAll': 'Clear all events? This cannot be undone.',
+ 'confirm.removeLock': 'Remove password protection? This will store data unencrypted in the URL.',
+
+ // Mobile warning
+ 'mobile.title': 'Mobile view notice',
+ 'mobile.message': "This app isn't optimized for mobile and tab view yet.",
+
+ // QR modal
+ 'qr.warning': 'Warning: URL is {{length}} characters. Some QR scanners may struggle with codes this large.',
+ 'qr.helper': 'Point your phone camera at this code to open your calendar.',
+
+ // JSON modal
+ 'json.urlHash': 'URL hash',
+ 'json.jsonData': 'JSON data',
+
+ // Locked overlay
+ 'locked.title': 'Encrypted calendar',
+ 'locked.message': 'Enter the password to unlock and edit this calendar.',
+
+ // Labels
+ 'label.details': 'Details',
+ 'label.events': 'Events',
+ 'label.clock': 'Clock',
+ 'label.calendar': 'Calendar',
+ 'label.language': 'Language',
+ 'label.close': 'Close',
+ 'label.menu': 'Menu',
+
+ // Countdown widget
+ 'countdown.upNext': 'Up Next',
+ 'countdown.startsAt': 'Starts at {{time}}',
+ 'countdown.starts': 'Starts {{date}} at {{time}}',
+
+ // Agenda view
+ 'agenda.title': 'Agenda',
+ 'agenda.rangeLabel': 'Agenda · {{range}}',
+
+ // Brand
+ 'brand.subtitle': 'Serverless privacy calendar. Your URL is the save file.',
+
+ // World Planner
+ 'planner.addTimezone': 'Add timezone (e.g. London)',
+
+ // Month names
+ 'month.january': 'January',
+ 'month.february': 'February',
+ 'month.march': 'March',
+ 'month.april': 'April',
+ 'month.may': 'May',
+ 'month.june': 'June',
+ 'month.july': 'July',
+ 'month.august': 'August',
+ 'month.september': 'September',
+ 'month.october': 'October',
+ 'month.november': 'November',
+ 'month.december': 'December',
+
+ // Short month names
+ 'month.short.jan': 'Jan',
+ 'month.short.feb': 'Feb',
+ 'month.short.mar': 'Mar',
+ 'month.short.apr': 'Apr',
+ 'month.short.may': 'May',
+ 'month.short.jun': 'Jun',
+ 'month.short.jul': 'Jul',
+ 'month.short.aug': 'Aug',
+ 'month.short.sep': 'Sep',
+ 'month.short.oct': 'Oct',
+ 'month.short.nov': 'Nov',
+ 'month.short.dec': 'Dec',
+
+ // Weekday names
+ 'weekday.sunday': 'Sunday',
+ 'weekday.monday': 'Monday',
+ 'weekday.tuesday': 'Tuesday',
+ 'weekday.wednesday': 'Wednesday',
+ 'weekday.thursday': 'Thursday',
+ 'weekday.friday': 'Friday',
+ 'weekday.saturday': 'Saturday',
+
+ // Short weekday names
+ 'weekday.short.sun': 'Sun',
+ 'weekday.short.mon': 'Mon',
+ 'weekday.short.tue': 'Tue',
+ 'weekday.short.wed': 'Wed',
+ 'weekday.short.thu': 'Thu',
+ 'weekday.short.fri': 'Fri',
+ 'weekday.short.sat': 'Sat',
+
+ // Narrow weekday names (for year view)
+ 'weekday.narrow.sun': 'S',
+ 'weekday.narrow.mon': 'M',
+ 'weekday.narrow.tue': 'T',
+ 'weekday.narrow.wed': 'W',
+ 'weekday.narrow.thu': 'T',
+ 'weekday.narrow.fri': 'F',
+ 'weekday.narrow.sat': 'S',
+};
diff --git a/locales/si.js b/locales/si.js
new file mode 100644
index 0000000..fcdbce7
--- /dev/null
+++ b/locales/si.js
@@ -0,0 +1,238 @@
+export default {
+ // Navigation
+ 'nav.prev': 'පෙර',
+ 'nav.today': 'අද',
+ 'nav.next': 'ඊළඟ',
+ 'nav.prevMonth': 'පෙර මාසය',
+ 'nav.nextMonth': 'ඊළඟ මාසය',
+
+ // View toggles
+ 'view.day': 'දවස',
+ 'view.week': 'සතිය',
+ 'view.month': 'මාසය',
+ 'view.year': 'අවුරුද්ද',
+ 'view.agenda': 'න්‍යාය පත්‍රය',
+
+ // Action buttons
+ 'btn.addEvent': 'සිදුවීම එක් කරන්න',
+ 'btn.copyLink': 'සබැඳිය පිටපත් කරන්න',
+ 'btn.shareQr': 'QR බෙදාගන්න',
+ 'btn.lock': 'අගුළු දමන්න',
+ 'btn.unlock': 'අගුළු අරින්න',
+ 'btn.removeLock': 'අගුළ ඉවත් කරන්න',
+ 'btn.focus': 'නාභිගත වන්න',
+ 'btn.exitFocus': 'නාභිගතයෙන් ඉවත් වන්න',
+ 'btn.save': 'සුරකින්න',
+ 'btn.cancel': 'අවලංගු කරන්න',
+ 'btn.delete': 'මකන්න',
+ 'btn.addEventForDay': 'මේ දවසට සිදුවීම එක් කරන්න',
+ 'btn.viewJson': 'JSON බලන්න',
+ 'btn.exportJson': 'JSON අපනයනය කරන්න',
+ 'btn.importIcs': '.ics ආයාත කරන්න',
+ 'btn.clearCalendar': 'දිනදර්ශනය මකන්න',
+ 'btn.addTimezone': 'වේලා කලාපය එක් කරන්න',
+ 'btn.gotIt': 'තේරුණා',
+ 'btn.copyJson': 'JSON පිටපත් කරන්න',
+ 'btn.copyHash': 'හෑෂ් පිටපත් කරන්න',
+ 'btn.downloadJson': 'JSON බාගන්න',
+ 'btn.copyTextLink': 'ඒ වෙනුවට පෙළ සබැඳිය පිටපත් කරන්න',
+ 'btn.worldPlanner': 'සැලසුම්කරු',
+ 'planner.notFound': 'වේලා කලාපය හමු නොවීය',
+ 'planner.homeTitle': 'ප්‍රධාන වේලාව ලෙස සකසන්න',
+ 'planner.removeTitle': 'ඉවත් කරන්න',
+ 'launcher.ariaLabel': 'යෙදුම් මෙනුව',
+ 'app.calendar': 'Hash Calendar',
+ 'app.spreadsheet': 'Spreadsheet Live',
+
+ // Modal titles
+ 'modal.addEvent': 'සිදුවීම එක් කරන්න',
+ 'modal.editEvent': 'සිදුවීම සංස්කරණය කරන්න',
+ 'modal.unlockCalendar': 'දිනදර්ශනය අගුළු අරින්න',
+ 'modal.setPassword': 'මුරපදය සකසන්න',
+ 'modal.shareData': 'දත්ත බෙදාගන්න',
+ 'modal.scanQr': 'ජංගම දුරකථනයේ විවෘත කිරීමට ස්කෑන් කරන්න',
+ 'modal.selectTimezone': 'වේලා කලාපය තෝරන්න',
+ 'modal.worldPlanner': 'ලෝක සැලසුම්කරු',
+
+ // Event form fields
+ 'event.title': 'මාතෘකාව',
+ 'event.date': 'දිනය',
+ 'event.start': 'ආරම්භය',
+ 'event.duration': 'කාල සීමාව (මිනිත්තු)',
+ 'event.allDay': 'මුළු දවස',
+ 'event.recurrence': 'පුනරාවර්තනය',
+ 'event.color': 'වර්ණය',
+
+ // Recurrence options
+ 'recurrence.none': 'කිසිවක් නැත',
+ 'recurrence.daily': 'දිනපතා',
+ 'recurrence.weekly': 'සතිපතා',
+ 'recurrence.monthly': 'මාසිකව',
+ 'recurrence.yearly': 'වාර්ෂිකව',
+
+ // Password form
+ 'password.password': 'මුරපදය',
+ 'password.confirmPassword': 'මුරපදය තහවුරු කරන්න',
+ 'password.setDesc': 'සබැඳිය සහ මුරපදය ඇති පුද්ගලයින්ට පමණක් මෙම දිනදර්ශනය කියවිය හැකි පරිදි මුරපදයක් එක් කරන්න.',
+ 'password.unlockDesc': 'මෙම දිනදර්ශනය විකේතනය කිරීමට මුරපදය ඇතුළත් කරන්න.',
+ 'password.required': 'මුරපදය අවශ්‍යයි.',
+ 'password.mismatch': 'මුරපද ගැලපෙන්නේ නැත.',
+
+ // Side panel sections
+ 'panel.selectedDay': 'තෝරාගත් දිනය',
+ 'panel.shareExport': 'බෙදාගැනීම සහ අපනයනය',
+ 'panel.dangerZone': 'අන්තරාදායක කලාපය',
+ 'panel.urlLength': 'URL දිග',
+ 'panel.urlWarning': 'අනතුරු ඇඟවීම: දිගු URL බෙදාගන්නා විට කපා හැරිය හැක.',
+
+ // Timezone/world clock
+ 'tz.worldClock': 'ලෝක ඔරලෝසුව',
+ 'tz.subtitle': 'දේශීය වේලාව සහ සුරකින ලද කලාප',
+ 'tz.search': 'සොයන්න',
+ 'tz.searchPlaceholder': 'සොයන්න (උදා: London)',
+ 'tz.noMatches': 'තවමත් ගැලපීම් නොමැත. නගරයක්, කලාපයක් හෝ UTC+5:30 උත්සාහ කරන්න.',
+ 'tz.addToCompare': 'සැසඳීමට වේලා කලාපයක් එක් කරන්න.',
+ 'tz.notSupported': 'මෙම බ්‍රව්සරයේ වේලා කලාප සෙවීම සහාය නොදක්වයි.',
+
+ // Focus mode
+ 'focus.nextUpIn': 'ඊළඟට',
+ 'focus.allClear': 'සියල්ල පැහැදිලියි',
+ 'focus.inProgress': 'ක්‍රියාත්මක වෙමින්',
+ 'focus.noUpcoming': 'ඉදිරි සිදුවීම් නොමැත',
+ 'focus.upLater': 'පසුව',
+
+ // Calendar display
+ 'calendar.allDay': 'මුළු දවස',
+ 'calendar.moreEvents': '+{{count}} තවත්',
+ 'calendar.noUpcoming': 'ඉදිරි සිදුවීම් නොමැත',
+ 'calendar.noEvents': 'තවමත් සිදුවීම් නොමැත.',
+
+ // Settings
+ 'settings.weekStartsSunday': 'සතිය ඉරිදා ආරම්භ වේ',
+ 'settings.weekStartsMonday': 'සතිය සඳුදා ආරම්භ වේ',
+ 'settings.themeLight': 'තේමාව: ආලෝකය',
+ 'settings.themeDark': 'තේමාව: අඳුරු',
+ 'settings.language': 'භාෂාව',
+
+ // Language names
+ 'lang.en': 'English',
+ 'lang.si': 'සිංහල',
+
+ // Toast messages
+ 'toast.linkCopied': 'සබැඳිය පිටපත් විය',
+ 'toast.eventsImported': 'සිදුවීම් ආයාත විය',
+ 'toast.eventDeleted': 'සිදුවීම මකා දමන ලදී',
+ 'toast.eventsCleared': 'සිදුවීම් මකා දමන ලදී',
+ 'toast.jsonCopied': 'JSON පිටපත් විය',
+ 'toast.hashCopied': 'හෑෂ් පිටපත් විය',
+ 'toast.lockRemoved': 'අගුළ ඉවත් කරන ලදී',
+ 'toast.calendarLocked': 'දිනදර්ශනය අගුළු දමන ලදී',
+ 'toast.calendarUnlocked': 'දිනදර්ශනය අගුළු ඇරිණි',
+ 'toast.incorrectPassword': 'වැරදි මුරපදයක්',
+ 'toast.unableToCopyLink': 'සබැඳිය පිටපත් කළ නොහැක',
+ 'toast.unableToCopyJson': 'JSON පිටපත් කළ නොහැක',
+ 'toast.unableToCopyHash': 'හෑෂ් පිටපත් කළ නොහැක',
+ 'toast.noEventsFound': 'සිදුවීම් හමු නොවීය',
+ 'toast.qrLibraryFailed': 'QR පුස්තකාලය පූරණය කිරීමට අසමත් විය',
+ 'toast.qrError': 'QR කේතය ජනනය කිරීමේදී දෝෂයකි',
+
+ // Confirmation dialogs
+ 'confirm.deleteEvent': 'මෙම සිදුවීම මකන්නද?',
+ 'confirm.clearAll': 'සියලුම සිදුවීම් මකන්නද? මෙය ආපසු හැරවිය නොහැක.',
+ 'confirm.removeLock': 'මුරපද ආරක්ෂාව ඉවත් කරන්නද? මෙය දත්ත URL හි සංකේතනය නොකර ගබඩා කරයි.',
+
+ // Mobile warning
+ 'mobile.title': 'ජංගම දසුන දැනුම්දීම',
+ 'mobile.message': 'මෙම යෙදුම තවමත් ජංගම සහ ටැබ් දර්ශනය සඳහා ප්‍රශස්තිකරණය කර නොමැත.',
+
+ // QR modal
+ 'qr.warning': 'අනතුරු ඇඟවීම: URL අක්ෂර {{length}} කි. සමහර QR ස්කෑනර් මෙතරම් විශාල කේත සමඟ අරගල කළ හැක.',
+ 'qr.helper': 'ඔබේ දිනදර්ශනය විවෘත කිරීමට මෙම කේතයට ඔබේ දුරකථන කැමරාව යොමු කරන්න.',
+
+ // JSON modal
+ 'json.urlHash': 'URL හෑෂ්',
+ 'json.jsonData': 'JSON දත්ත',
+
+ // Locked overlay
+ 'locked.title': 'සංකේතිත දිනදර්ශනය',
+ 'locked.message': 'මෙම දිනදර්ශනය අගුළු හැරීමට සහ සංස්කරණය කිරීමට මුරපදය ඇතුළත් කරන්න.',
+
+ // Labels
+ 'label.details': 'විස්තර',
+ 'label.events': 'සිදුවීම්',
+ 'label.clock': 'ඔරලෝසුව',
+ 'label.calendar': 'දිනදර්ශනය',
+ 'label.language': 'භාෂාව',
+ 'label.close': 'වසන්න',
+ 'label.menu': 'මෙනුව',
+
+ // Countdown widget
+ 'countdown.upNext': 'ඊළඟට',
+ 'countdown.startsAt': '{{time}} ට ආරම්භ වේ',
+ 'countdown.starts': '{{date}} {{time}} ට ආරම්භ වේ',
+
+ // Agenda view
+ 'agenda.title': 'න්‍යාය පත්‍රය',
+ 'agenda.rangeLabel': 'න්‍යාය පත්‍රය · {{range}}',
+
+ // Brand
+ 'brand.subtitle': 'සේවාදායකයක් නොමැති රහස්‍යතා දිනදර්ශනය. ඔබේ URL සුරැකුම් ගොනුවයි.',
+
+ // World Planner
+ 'planner.addTimezone': 'වේලා කලාපය එක් කරන්න (උදා: London)',
+
+ // Month names
+ 'month.january': 'ජනවාරි',
+ 'month.february': 'පෙබරවාරි',
+ 'month.march': 'මාර්තු',
+ 'month.april': 'අප්‍රේල්',
+ 'month.may': 'මැයි',
+ 'month.june': 'ජූනි',
+ 'month.july': 'ජූලි',
+ 'month.august': 'අගෝස්තු',
+ 'month.september': 'සැප්තැම්බර්',
+ 'month.october': 'ඔක්තෝබර්',
+ 'month.november': 'නොවැම්බර්',
+ 'month.december': 'දෙසැම්බර්',
+
+ // Short month names
+ 'month.short.jan': 'ජන',
+ 'month.short.feb': 'පෙබ',
+ 'month.short.mar': 'මාර්',
+ 'month.short.apr': 'අප්‍රේල්',
+ 'month.short.may': 'මැයි',
+ 'month.short.jun': 'ජූනි',
+ 'month.short.jul': 'ජූලි',
+ 'month.short.aug': 'අගෝ',
+ 'month.short.sep': 'සැප්',
+ 'month.short.oct': 'ඔක්',
+ 'month.short.nov': 'නොවැ',
+ 'month.short.dec': 'දෙසැ',
+
+ // Weekday names
+ 'weekday.sunday': 'ඉරිදා',
+ 'weekday.monday': 'සඳුදා',
+ 'weekday.tuesday': 'අඟහරුවාදා',
+ 'weekday.wednesday': 'බදාදා',
+ 'weekday.thursday': 'බ්‍රහස්පතින්දා',
+ 'weekday.friday': 'සිකුරාදා',
+ 'weekday.saturday': 'සෙනසුරාදා',
+
+ // Short weekday names
+ 'weekday.short.sun': 'ඉරි',
+ 'weekday.short.mon': 'සඳු',
+ 'weekday.short.tue': 'අඟ',
+ 'weekday.short.wed': 'බදා',
+ 'weekday.short.thu': 'බ්‍රහ',
+ 'weekday.short.fri': 'සිකු',
+ 'weekday.short.sat': 'සෙන',
+
+ // Narrow weekday names (for year view)
+ 'weekday.narrow.sun': 'ඉ',
+ 'weekday.narrow.mon': 'ස',
+ 'weekday.narrow.tue': 'අ',
+ 'weekday.narrow.wed': 'බ',
+ 'weekday.narrow.thu': 'බ්‍ර',
+ 'weekday.narrow.fri': 'සි',
+ 'weekday.narrow.sat': 'සෙ',
+};
diff --git a/modules/agendaRender.js b/modules/agendaRender.js
index 6f58a2c..82ab45f 100644
--- a/modules/agendaRender.js
+++ b/modules/agendaRender.js
@@ -1,5 +1,6 @@
import { expandEvents } from "./recurrenceEngine.js";
import { formatDateKey } from "./calendarRender.js";
+import { t, getCurrentLocale } from "./i18n.js";
const DEFAULT_COLORS = ["#ff6b6b", "#ffd43b", "#4dabf7", "#63e6be", "#9775fa"];
@@ -22,7 +23,7 @@ function addMonths(date, months) {
}
function formatAgendaHeader(date) {
- return date.toLocaleDateString(undefined, {
+ return date.toLocaleDateString(getCurrentLocale(), {
weekday: "short",
month: "short",
day: "numeric",
@@ -30,14 +31,14 @@ function formatAgendaHeader(date) {
}
function formatAgendaTime(date) {
- return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
+ return date.toLocaleTimeString(getCurrentLocale(), { hour: "2-digit", minute: "2-digit" });
}
function decorateOccurrences(occurrences, colors) {
const palette = Array.isArray(colors) && colors.length ? colors : DEFAULT_COLORS;
return occurrences.map((occ) => {
const color = palette[occ.colorIndex] || palette[0] || "#4dabf7";
- const timeLabel = occ.isAllDay ? "All day" : formatAgendaTime(new Date(occ.start));
+ const timeLabel = occ.isAllDay ? t("calendar.allDay") : formatAgendaTime(new Date(occ.start));
return { ...occ, color, timeLabel };
});
}
@@ -69,7 +70,7 @@ export function renderAgendaView({ events, colors, container, rangeMonths = 6, o
if (!data.occurrences.length) {
const empty = document.createElement("div");
empty.className = "agenda-empty";
- empty.textContent = "No upcoming events.";
+ empty.textContent = t("calendar.noUpcoming");
container.appendChild(empty);
return data;
}
@@ -96,7 +97,7 @@ export function renderAgendaView({ events, colors, container, rangeMonths = 6, o
const time = document.createElement("div");
time.className = "agenda-time";
- time.textContent = event.isAllDay ? "All day" : formatAgendaTime(date);
+ time.textContent = event.timeLabel;
const details = document.createElement("div");
details.className = "agenda-details";
diff --git a/modules/app_launcher.js b/modules/app_launcher.js
index 0d3d5ac..db3f070 100644
--- a/modules/app_launcher.js
+++ b/modules/app_launcher.js
@@ -1,18 +1,16 @@
-/**
- * AppLauncher Module
- * Handles the "Waffle" menu for ecosystem apps.
- */
+import { onLanguageChange, t } from './i18n.js';
+
export class AppLauncher {
constructor() {
this.apps = [
{
- name: 'Hash Calendar',
+ nameKey: 'app.calendar',
url: 'https://hash-calendar.netlify.app/',
icon: 'fa-solid fa-calendar-days',
color: '#1a73e8'
},
{
- name: 'Spreadsheet Live',
+ nameKey: 'app.spreadsheet',
url: 'https://spreadsheetlive.netlify.app/',
icon: 'fa-solid fa-table-cells',
color: '#107c41'
@@ -20,8 +18,11 @@ export class AppLauncher {
];
this.init();
+ onLanguageChange(() => this.renderMenu());
}
+
+
init() {
this.renderMenu();
this.setupEventListeners();
@@ -49,7 +50,7 @@ export class AppLauncher {
<div class="app-icon-wrapper" style="background-color: ${app.color}15; color: ${app.color}">
<i class="${app.icon}"></i>
</div>
- <span class="app-name">${app.name}</span>
+ <span class="app-name">${window.t ? window.t(app.nameKey) : app.nameKey}</span>
`;
grid.appendChild(appItem);
diff --git a/modules/calendarRender.js b/modules/calendarRender.js
index 70fe83f..c7345c4 100644
--- a/modules/calendarRender.js
+++ b/modules/calendarRender.js
@@ -1,3 +1,5 @@
+import { t, getCurrentLocale, getTranslatedMonthName, getTranslatedWeekday } from "./i18n.js";
+
function pad(num) {
return String(num).padStart(2, "0");
}
@@ -37,25 +39,26 @@ export function getWeekRange(viewDate, weekStartsOnMonday) {
}
function formatWeekdayLabel(date) {
- return date.toLocaleDateString(undefined, { weekday: "short" });
+ return getTranslatedWeekday(date, 'short');
}
export function renderWeekdayHeaders(container, weekStartsOnMonday, mode = "month", dates = []) {
+ const locale = getCurrentLocale();
let labels = [];
if (mode === "day" && dates[0]) {
- labels = [
- dates[0].toLocaleDateString(undefined, {
- weekday: "long",
- month: "short",
- day: "numeric",
- }),
- ];
+ const date = dates[0];
+ labels = [`${getTranslatedWeekday(date)}, ${getTranslatedMonthName(date, true)} ${date.getDate()}`];
} else if (mode === "week" && dates.length) {
labels = dates.map((date) => `${formatWeekdayLabel(date)} ${date.getDate()}`);
} else {
- labels = weekStartsOnMonday
- ? ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
- : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+ // Generate weekday labels dynamically based on locale
+ const baseDate = new Date(2024, 0, 1); // Monday, January 1, 2024
+ const offset = weekStartsOnMonday ? 0 : 6;
+ labels = Array.from({ length: 7 }, (_, i) => {
+ const date = new Date(baseDate);
+ date.setDate(1 + ((i + offset) % 7));
+ return getTranslatedWeekday(date, 'short');
+ });
}
container.innerHTML = "";
@@ -108,7 +111,7 @@ export function renderCalendar({
const time = document.createElement("span");
time.className = "time";
- time.textContent = event.isAllDay ? "All day" : event.timeLabel;
+ time.textContent = event.timeLabel;
const title = document.createElement("span");
title.textContent = event.title;
@@ -124,7 +127,7 @@ export function renderCalendar({
if (events.length > maxEvents) {
const more = document.createElement("div");
more.className = "event-more";
- more.textContent = `+${events.length - maxEvents} more`;
+ more.textContent = t("calendar.moreEvents", { count: events.length - maxEvents });
dayCell.appendChild(more);
}
@@ -170,7 +173,7 @@ export function renderTimeGrid({ container, dates, occurrences, onSelectDay, onE
const allDayLabel = document.createElement("div");
allDayLabel.className = "time-label all-day-label";
- allDayLabel.textContent = "All day";
+ allDayLabel.textContent = t("calendar.allDay");
container.appendChild(allDayLabel);
dates.forEach((date) => {
@@ -195,7 +198,7 @@ export function renderTimeGrid({ container, dates, occurrences, onSelectDay, onE
if (events.length > 2) {
const more = document.createElement("div");
more.className = "event-more";
- more.textContent = `+${events.length - 2} more`;
+ more.textContent = t("calendar.moreEvents", { count: events.length - 2 });
cell.appendChild(more);
}
cell.addEventListener("click", () => onSelectDay(date));
@@ -231,7 +234,7 @@ export function renderTimeGrid({ container, dates, occurrences, onSelectDay, onE
if (events.length > 3) {
const more = document.createElement("div");
more.className = "event-more";
- more.textContent = `+${events.length - 3} more`;
+ more.textContent = t("calendar.moreEvents", { count: events.length - 3 });
cell.appendChild(more);
}
cell.addEventListener("click", () => onSelectDay(date));
@@ -240,67 +243,73 @@ export function renderTimeGrid({ container, dates, occurrences, onSelectDay, onE
}
}
-export function renderYearView({ container, year, eventsByDay, selectedDate, weekStartsOnMonday, onSelectDay }) {
- container.innerHTML = "";
- container.style.gridTemplateColumns = "repeat(auto-fit, minmax(220px, 1fr))";
- container.style.gridTemplateRows = "auto";
-
- const labels = weekStartsOnMonday
- ? ["M", "T", "W", "T", "F", "S", "S"]
- : ["S", "M", "T", "W", "T", "F", "S"];
-
- for (let month = 0; month < 12; month += 1) {
+export function renderYearView({ container, year, eventsByDay, selectedDate, weekStartsOnMonday, onSelectDay }) {
+ const locale = getCurrentLocale();
+ container.innerHTML = "";
+ container.style.gridTemplateColumns = "repeat(auto-fit, minmax(220px, 1fr))";
+ container.style.gridTemplateRows = "auto";
+
+ // Generate weekday abbreviations dynamically based on locale
+ const baseDate = new Date(2024, 0, 1); // Monday, January 1, 2024
+ const offset = weekStartsOnMonday ? 0 : 6;
+ const labels = Array.from({ length: 7 }, (_, i) => {
+ const date = new Date(baseDate);
+ date.setDate(1 + ((i + offset) % 7));
+ return getTranslatedWeekday(date, 'narrow');
+ });
+
+ for (let month = 0; month < 12; month += 1) {
const wrapper = document.createElement("div");
wrapper.className = "mini-month";
const header = document.createElement("div");
header.className = "mini-title";
- header.textContent = new Date(year, month, 1).toLocaleDateString(undefined, { month: "long" });
+ header.textContent = getTranslatedMonthName(new Date(year, month, 1));
wrapper.appendChild(header);
const grid = document.createElement("div");
grid.className = "mini-grid";
- labels.forEach((label) => {
- const cell = document.createElement("div");
- cell.className = "mini-weekday";
- cell.textContent = label;
- grid.appendChild(cell);
- });
-
- const firstOfMonth = new Date(year, month, 1);
- const dayOfWeek = firstOfMonth.getDay();
- const offset = weekStartsOnMonday ? (dayOfWeek + 6) % 7 : dayOfWeek;
- const daysInMonth = new Date(year, month + 1, 0).getDate();
- const totalCells = Math.ceil((offset + daysInMonth) / 7) * 7;
-
- for (let i = 0; i < totalCells; i += 1) {
- const dayIndex = i - offset + 1;
- if (i < offset || dayIndex > daysInMonth) {
- const emptyCell = document.createElement("div");
- emptyCell.className = "mini-day is-empty";
- emptyCell.setAttribute("aria-hidden", "true");
- grid.appendChild(emptyCell);
- continue;
- }
-
- const date = new Date(year, month, dayIndex);
- const key = formatDateKey(date);
- const dayCell = document.createElement("button");
- dayCell.type = "button";
- dayCell.className = "mini-day";
- if (selectedDate && key === formatDateKey(selectedDate)) dayCell.classList.add("is-selected");
- dayCell.textContent = String(dayIndex);
- if (eventsByDay.has(key)) {
- const dot = document.createElement("span");
- dot.className = "mini-dot";
- dayCell.appendChild(dot);
- }
- dayCell.addEventListener("click", () => onSelectDay(date));
- grid.appendChild(dayCell);
- }
-
- wrapper.appendChild(grid);
- container.appendChild(wrapper);
- }
-}
+ labels.forEach((label) => {
+ const cell = document.createElement("div");
+ cell.className = "mini-weekday";
+ cell.textContent = label;
+ grid.appendChild(cell);
+ });
+
+ const firstOfMonth = new Date(year, month, 1);
+ const dayOfWeek = firstOfMonth.getDay();
+ const offset = weekStartsOnMonday ? (dayOfWeek + 6) % 7 : dayOfWeek;
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
+ const totalCells = Math.ceil((offset + daysInMonth) / 7) * 7;
+
+ for (let i = 0; i < totalCells; i += 1) {
+ const dayIndex = i - offset + 1;
+ if (i < offset || dayIndex > daysInMonth) {
+ const emptyCell = document.createElement("div");
+ emptyCell.className = "mini-day is-empty";
+ emptyCell.setAttribute("aria-hidden", "true");
+ grid.appendChild(emptyCell);
+ continue;
+ }
+
+ const date = new Date(year, month, dayIndex);
+ const key = formatDateKey(date);
+ const dayCell = document.createElement("button");
+ dayCell.type = "button";
+ dayCell.className = "mini-day";
+ if (selectedDate && key === formatDateKey(selectedDate)) dayCell.classList.add("is-selected");
+ dayCell.textContent = String(dayIndex);
+ if (eventsByDay.has(key)) {
+ const dot = document.createElement("span");
+ dot.className = "mini-dot";
+ dayCell.appendChild(dot);
+ }
+ dayCell.addEventListener("click", () => onSelectDay(date));
+ grid.appendChild(dayCell);
+ }
+
+ wrapper.appendChild(grid);
+ container.appendChild(wrapper);
+ }
+}
diff --git a/modules/countdownManager.js b/modules/countdownManager.js
index 3919c31..1acc2d2 100644
--- a/modules/countdownManager.js
+++ b/modules/countdownManager.js
@@ -1,4 +1,5 @@
import { expandEvents } from "./recurrenceEngine.js";
+import { t, getCurrentLocale } from "./i18n.js";
const LOOKAHEAD_DAYS = 30;
const URGENCY_MS = 5 * 60 * 1000;
@@ -19,11 +20,11 @@ function isSameDay(a, b) {
}
function formatTime(date) {
- return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
+ return date.toLocaleTimeString(getCurrentLocale(), { hour: "2-digit", minute: "2-digit" });
}
function formatDateLabel(date) {
- return date.toLocaleDateString(undefined, { weekday: "short", month: "short", day: "numeric" });
+ return date.toLocaleDateString(getCurrentLocale(), { weekday: "short", month: "short", day: "numeric" });
}
function formatDuration(ms) {
@@ -46,15 +47,15 @@ function formatMeta(event, now) {
if (!event) return "";
const startDate = event.startDate || new Date(event.start);
if (event.isAllDay) {
- if (isSameDay(startDate, now)) return "All day";
- return `All day ${formatDateLabel(startDate)}`;
+ if (isSameDay(startDate, now)) return t("calendar.allDay");
+ return `${t("calendar.allDay")} ${formatDateLabel(startDate)}`;
}
const timeLabel = formatTime(startDate);
if (isSameDay(startDate, now)) {
- return `Starts at ${timeLabel}`;
+ return t("countdown.startsAt", { time: timeLabel });
}
- return `Starts ${formatDateLabel(startDate)} at ${timeLabel}`;
+ return t("countdown.starts", { date: formatDateLabel(startDate), time: timeLabel });
}
function getElements() {
diff --git a/modules/focusMode.js b/modules/focusMode.js
index 5415b41..69c3753 100644
--- a/modules/focusMode.js
+++ b/modules/focusMode.js
@@ -1,4 +1,5 @@
import { expandEvents } from "./recurrenceEngine.js";
+import { t, getCurrentLocale } from "./i18n.js";
const MAX_UP_NEXT = 2;
@@ -25,11 +26,11 @@ function isSameDay(a, b) {
}
function formatTime(date) {
- return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
+ return date.toLocaleTimeString(getCurrentLocale(), { hour: "2-digit", minute: "2-digit" });
}
function formatDateLabel(date) {
- return date.toLocaleDateString(undefined, { weekday: "short", month: "short", day: "numeric" });
+ return date.toLocaleDateString(getCurrentLocale(), { weekday: "short", month: "short", day: "numeric" });
}
function formatCountdown(ms) {
@@ -47,14 +48,14 @@ function formatEventTime(event, now) {
if (!event) return "";
const dateLabel = isSameDay(event.startDate, now) ? "" : `${formatDateLabel(event.startDate)} | `;
if (event.isAllDay) {
- return `${dateLabel}All day`.trim();
+ return `${dateLabel}${t("calendar.allDay")}`.trim();
}
return `${dateLabel}${formatTime(event.startDate)} - ${formatTime(event.endDate)}`.trim();
}
function formatUpNextLabel(event, now) {
const dateLabel = isSameDay(event.startDate, now) ? "" : `${formatDateLabel(event.startDate)} `;
- const timeLabel = event.isAllDay ? "All day" : formatTime(event.startDate);
+ const timeLabel = event.isAllDay ? t("calendar.allDay") : formatTime(event.startDate);
return `${dateLabel}${timeLabel}`.trim();
}
@@ -136,9 +137,9 @@ export class FocusMode {
const { mode, primary, upcoming } = this.getDisplayState(now);
if (mode === "empty" || !primary) {
this.setTone("neutral");
- if (this.statusEl) this.statusEl.textContent = "ALL CLEAR";
+ if (this.statusEl) this.statusEl.textContent = t("focus.allClear");
if (this.timerEl) this.timerEl.textContent = "--:--:--";
- if (this.titleEl) this.titleEl.textContent = "No upcoming events";
+ if (this.titleEl) this.titleEl.textContent = t("focus.noUpcoming");
if (this.timeEl) {
this.timeEl.textContent = "";
this.timeEl.classList.add("hidden");
@@ -156,13 +157,13 @@ export class FocusMode {
if (mode === "active") {
const diff = Math.max(primary.endDate - now, 0);
if (this.statusEl) {
- this.statusEl.textContent = primary.isAllDay ? "ALL DAY" : "IN PROGRESS";
+ this.statusEl.textContent = primary.isAllDay ? t("calendar.allDay").toUpperCase() : t("focus.inProgress");
}
if (this.timerEl) this.timerEl.textContent = formatCountdown(diff);
this.setTone("urgent");
} else {
const diff = Math.max(primary.startDate - now, 0);
- if (this.statusEl) this.statusEl.textContent = "NEXT UP IN";
+ if (this.statusEl) this.statusEl.textContent = t("focus.nextUpIn");
if (this.timerEl) this.timerEl.textContent = formatCountdown(diff);
this.setTone(getToneForDiff(diff));
}
diff --git a/modules/i18n.js b/modules/i18n.js
new file mode 100644
index 0000000..c4bed8b
--- /dev/null
+++ b/modules/i18n.js
@@ -0,0 +1,109 @@
+import en from "../locales/en.js";
+import si from "../locales/si.js";
+
+const translations = { en, si };
+export const SUPPORTED_LANGUAGES = [
+ { code: 'en', nameKey: 'lang.en' },
+ { code: 'si', nameKey: 'lang.si' }
+];
+let currentLang = "en";
+const updateCallbacks = [];
+
+/**
+ * Set the current language and update the DOM
+ * @param {string} lang - Language code ('en' or 'si')
+ */
+export function setLanguage(lang) {
+ if (translations[lang]) {
+ currentLang = lang;
+ document.documentElement.setAttribute('lang', lang === 'si' ? 'si' : 'en');
+ localStorage.setItem("hashcal.language", lang);
+ updateDOM();
+ updateCallbacks.forEach(cb => cb(lang));
+ }
+}
+
+/**
+ * Register a callback to be called when the language changes
+ * @param {Function} cb - Callback function
+ */
+export function onLanguageChange(cb) {
+ updateCallbacks.push(cb);
+}
+
+/**
+ * Get translation for a key with optional variable replacements
+ * @param {string} key - Translation key
+ * @param {Object} replacements - Variables to replace in the translation
+ * @returns {string} Translated text
+ */
+export function t(key, replacements = {}) {
+ let text = translations[currentLang][key] || key;
+ Object.keys(replacements).forEach(varKey => {
+ text = text.replace(new RegExp(`{{${varKey}}}`, 'g'), replacements[varKey]);
+ });
+ return text;
+}
+
+/**
+ * Update all elements with data-i18n attributes
+ */
+export function updateDOM() {
+ // Update text content
+ document.querySelectorAll("[data-i18n]").forEach((el) => {
+ el.textContent = t(el.getAttribute("data-i18n"));
+ });
+
+ // Update placeholders
+ document.querySelectorAll("[data-i18n-placeholder]").forEach((el) => {
+ el.placeholder = t(el.getAttribute("data-i18n-placeholder"));
+ });
+
+ // Update aria-labels
+ document.querySelectorAll("[data-i18n-aria-label]").forEach((el) => {
+ el.setAttribute("aria-label", t(el.getAttribute("data-i18n-aria-label")));
+ });
+}
+
+/**
+ * Get current language code
+ * @returns {string} Current language code ('en' or 'si')
+ */
+export function getCurrentLanguage() {
+ return currentLang;
+}
+
+/**
+ * Get current locale string for Intl API
+ * @returns {string} Locale string ('en-US' or 'si-LK')
+ */
+export function getCurrentLocale() {
+ return currentLang === 'si' ? 'si-LK' : 'en-US';
+}
+
+// Date helpers using translations
+const MONTH_KEYS = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
+const MONTH_KEYS_SHORT = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
+const DAY_KEYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
+const DAY_KEYS_SHORT = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+
+export function getTranslatedMonthName(date, short = false) {
+ const idx = date.getMonth();
+ const key = short ? `month.short.${MONTH_KEYS_SHORT[idx]}` : `month.${MONTH_KEYS[idx]}`;
+ return t(key);
+}
+
+export function getTranslatedWeekday(date, type = 'long') {
+ const idx = date.getDay();
+ if (type === 'narrow') {
+ return t(`weekday.narrow.${DAY_KEYS_SHORT[idx]}`);
+ }
+ if (type === 'short') {
+ return t(`weekday.short.${DAY_KEYS_SHORT[idx]}`);
+ }
+ return t(`weekday.${DAY_KEYS[idx]}`);
+}
+
+// Auto-initialize from localStorage or default to 'en'
+const savedLang = localStorage.getItem("hashcal.language") || "en";
+setLanguage(savedLang);
diff --git a/modules/qrCodeManager.js b/modules/qrCodeManager.js
index 34c142c..618bc1a 100644
--- a/modules/qrCodeManager.js
+++ b/modules/qrCodeManager.js
@@ -1,3 +1,5 @@
+import { t } from "./i18n.js";
+
const MAX_QR_URL_LENGTH = 2000;
const DEFAULT_QR_SIZE = 256;
@@ -46,15 +48,15 @@ export function initQRCodeManager({
if (typeof window.QRCode === "undefined") {
if (typeof showToast === "function") {
- showToast("QR library failed to load", "error");
+ showToast(t("toast.qrLibraryFailed"), "error");
} else {
- window.alert("QR library failed to load.");
+ window.alert(t("toast.qrLibraryFailed"));
}
return;
}
if (url.length > maxLength) {
- showWarning(`Calendar data too long for QR transfer (${url.length} chars). Try deleting old events.`);
+ showWarning(t("qr.warning", { length: url.length }));
modal.classList.remove("hidden");
return;
}
@@ -72,9 +74,9 @@ export function initQRCodeManager({
} catch (error) {
console.error("QR generation error", error);
if (typeof showToast === "function") {
- showToast("Error creating QR code", "error");
+ showToast(t("toast.qrError"), "error");
} else {
- window.alert("Error creating QR code.");
+ window.alert(t("toast.qrError"));
}
}
}
diff --git a/planner_logic.js b/planner_logic.js
index f1710cc..15b872c 100644
--- a/planner_logic.js
+++ b/planner_logic.js
@@ -75,7 +75,7 @@ function handlePlannerAddZone() {
ui.wpAddZone.value = "";
}
} else {
- showToast("Timezone not found", "error");
+ showToast(t("planner.notFound"), "error");
}
}
@@ -182,8 +182,8 @@ function createPlannerCityHeader(zone, isHome) {
const controls = document.createElement("div");
controls.className = "wp-row-controls";
controls.innerHTML = `
- <button class="wp-control-btn" data-action="promote" data-zone="${zone}" title="Make Home"><i class="fa-solid fa-arrow-up"></i></button>
- <button class="wp-control-btn" data-action="remove" data-zone="${zone}" title="Remove"><i class="fa-solid fa-xmark"></i></button>
+ <button class="wp-control-btn" data-action="promote" data-zone="${zone}" title="${t('planner.homeTitle')}"><i class="fa-solid fa-arrow-up"></i></button>
+ <button class="wp-control-btn" data-action="remove" data-zone="${zone}" title="${t('planner.removeTitle')}"><i class="fa-solid fa-xmark"></i></button>
`;
div.appendChild(controls);
} else {
@@ -354,7 +354,8 @@ function createPlannerRow(zone, baseDate, isHome) {
// Show date abbrev
const d = new Date(baseDate);
d.setDate(d.getDate() + dayShift);
- cell.textContent = d.toLocaleDateString('en-US', { day: 'numeric', month: 'short' }).toUpperCase();
+ const translatedMonth = getTranslatedMonthName(d, true);
+ cell.textContent = `${translatedMonth} ${d.getDate()}`.toUpperCase();
} else {
// Format: "9 am" or "14:30"
let label = "";
diff --git a/script.js b/script.js
index f4b7340..ccfec0e 100644
--- a/script.js
+++ b/script.js
@@ -16,6 +16,15 @@ import {
} from "./modules/calendarRender.js";
import { parseIcs } from "./modules/icsImporter.js";
import { AppLauncher } from "./modules/app_launcher.js";
+import {
+ setLanguage,
+ t,
+ updateDOM,
+ getCurrentLanguage,
+ getCurrentLocale,
+ getTranslatedMonthName,
+ getTranslatedWeekday,
+} from "./modules/i18n.js";
const DEFAULT_COLORS = ["#ff6b6b", "#ffd43b", "#4dabf7", "#63e6be", "#9775fa"];
const DEFAULT_VIEW = "month";
@@ -37,8 +46,6 @@ const DEBOUNCE_MS = 500;
const MAX_TITLE_LENGTH = 60;
const MAX_TZ_RESULTS = 12;
const TZ_EMPTY_MESSAGE = "No matches yet. Try a city, region, or UTC+5:30.";
-const MOBILE_WARNING_QUERY = "(max-width: 1024px)";
-const MOBILE_WARNING_KEY = "hashcal.mobileWarningDismissed";
let state = cloneState(DEFAULT_STATE);
let viewDate = startOfDay(new Date());
@@ -99,43 +106,29 @@ function addDays(date, days) {
}
function formatMonthLabel(date) {
- return date.toLocaleDateString(undefined, { month: "long", year: "numeric" });
+ return `${getTranslatedMonthName(date)} ${date.getFullYear()}`;
}
function formatDateLabel(date) {
- return date.toLocaleDateString(undefined, { weekday: "long", month: "long", day: "numeric" });
+ return `${getTranslatedWeekday(date)}, ${getTranslatedMonthName(date)} ${date.getDate()}`;
}
function formatRangeLabel(start, end) {
const sameYear = start.getFullYear() === end.getFullYear();
const sameMonth = sameYear && start.getMonth() === end.getMonth();
if (sameMonth) {
- return `${start.toLocaleDateString(undefined, {
- month: "long",
- })} ${start.getDate()}–${end.getDate()}, ${start.getFullYear()}`;
+ return `${getTranslatedMonthName(start)} ${start.getDate()}–${end.getDate()}, ${start.getFullYear()}`;
}
if (sameYear) {
- return `${start.toLocaleDateString(undefined, {
- month: "short",
- day: "numeric",
- })} – ${end.toLocaleDateString(undefined, {
- month: "short",
- day: "numeric",
- })}, ${start.getFullYear()}`;
- }
- return `${start.toLocaleDateString(undefined, {
- month: "short",
- day: "numeric",
- year: "numeric",
- })} – ${end.toLocaleDateString(undefined, {
- month: "short",
- day: "numeric",
- year: "numeric",
- })}`;
+ return `${getTranslatedMonthName(start, true)} ${start.getDate()} – ${getTranslatedMonthName(end, true)} ${end.getDate()}, ${start.getFullYear()}`;
+ }
+ return `${getTranslatedMonthName(start, true)} ${start.getDate()}, ${start.getFullYear()} – ${getTranslatedMonthName(end, true)} ${end.getDate()}, ${end.getFullYear()}`;
}
function formatTime(date) {
- return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
+ // Use Intl for time as it is usually reliable (numbers/colons) or we can just stick to it.
+ // Actually, let's stick to locale sensitive time, it usually works fine (HH:mm).
+ return date.toLocaleTimeString(getCurrentLocale(), { hour: "2-digit", minute: "2-digit" });
}
function getStoredView(view) {
@@ -229,8 +222,6 @@ function normalizeState(raw) {
}
function cacheElements() {
- ui.mobileWarning = document.getElementById("mobile-warning");
- ui.mobileWarningDismiss = document.getElementById("mobile-warning-dismiss");
ui.topbar = document.querySelector(".topbar");
ui.titleInput = document.getElementById("calendar-title");
ui.prevMonth = document.getElementById("prev-month");
@@ -244,6 +235,10 @@ function cacheElements() {
ui.viewButtons = Array.from(document.querySelectorAll(".view-toggle button"));
ui.weekstartToggle = document.getElementById("weekstart-toggle");
ui.themeToggle = document.getElementById("theme-toggle");
+ ui.langBtn = document.getElementById("language-btn");
+ ui.langList = document.getElementById("language-list");
+ ui.currentLang = document.getElementById("current-lang");
+ ui.langDropdown = document.getElementById("language-dropdown");
ui.monthLabel = document.getElementById("month-label");
ui.weekdayRow = document.getElementById("weekday-row");
ui.calendarGrid = document.getElementById("calendar-grid");
@@ -334,54 +329,6 @@ function showToast(message, type = "info") {
}, 3200);
}
-function isMobileViewport() {
- if (window.matchMedia) {
- return window.matchMedia(MOBILE_WARNING_QUERY).matches;
- }
- return window.innerWidth <= 720;
-}
-
-function getMobileWarningDismissed() {
- try {
- return window.localStorage.getItem(MOBILE_WARNING_KEY) === "1";
- } catch (error) {
- return false;
- }
-}
-
-function setMobileWarningDismissed() {
- try {
- window.localStorage.setItem(MOBILE_WARNING_KEY, "1");
- } catch (error) {
- // Ignore storage errors (private mode, blocked, etc.).
- }
-}
-
-function updateMobileWarningVisibility() {
- if (!ui.mobileWarning) return;
- const shouldShow = isMobileViewport() && !getMobileWarningDismissed();
- ui.mobileWarning.classList.toggle("hidden", !shouldShow);
-}
-
-function dismissMobileWarning() {
- setMobileWarningDismissed();
- if (ui.mobileWarning) ui.mobileWarning.classList.add("hidden");
-}
-
-function initMobileWarning() {
- if (!ui.mobileWarning) return;
- updateMobileWarningVisibility();
- window.addEventListener("resize", updateMobileWarningVisibility);
- if (!window.matchMedia) return;
- const mediaQuery = window.matchMedia(MOBILE_WARNING_QUERY);
- const handleChange = () => updateMobileWarningVisibility();
- if (mediaQuery.addEventListener) {
- mediaQuery.addEventListener("change", handleChange);
- } else if (mediaQuery.addListener) {
- mediaQuery.addListener(handleChange);
- }
-}
-
function hasStoredData() {
return (state.e && state.e.length) || (state.timezones && state.timezones.length);
}
@@ -430,7 +377,7 @@ function renderTimezones() {
if (!added) {
const empty = document.createElement("p");
empty.className = "tz-empty";
- empty.textContent = "Add a timezone to compare.";
+ empty.textContent = t("tz.addToCompare");
ui.tzList.appendChild(empty);
}
}
@@ -532,7 +479,7 @@ function handleTzSearch() {
const offsetQuery = parseOffsetSearchTerm(term);
if (!AVAILABLE_ZONES.length) {
if (ui.tzEmpty) {
- ui.tzEmpty.textContent = "Timezone search isn't supported in this browser.";
+ ui.tzEmpty.textContent = t("tz.notSupported");
ui.tzEmpty.classList.remove("hidden");
}
renderTzResults([]);
@@ -666,7 +613,7 @@ function updateUrlLength() {
if (ui.urlLength) ui.urlLength.textContent = String(length);
if (!ui.urlWarning) return;
if (length > 2000) {
- ui.urlWarning.textContent = "Warning: long URLs may get truncated when shared.";
+ ui.urlWarning.textContent = t("panel.urlWarning");
} else {
ui.urlWarning.textContent = "";
}
@@ -675,7 +622,7 @@ function updateUrlLength() {
function updateTheme() {
document.body.dataset.theme = state.s.d ? "dark" : "light";
if (ui.themeToggle) {
- ui.themeToggle.textContent = `Theme: ${state.s.d ? "Dark" : "Light"}`;
+ ui.themeToggle.textContent = t(state.s.d ? "settings.themeDark" : "settings.themeLight");
}
}
@@ -686,13 +633,13 @@ function syncTopbarHeight() {
function updateWeekStartLabel() {
if (!ui.weekstartToggle) return;
- ui.weekstartToggle.textContent = state.s.m ? "Week starts Monday" : "Week starts Sunday";
+ ui.weekstartToggle.textContent = t(state.s.m ? "settings.weekStartsMonday" : "settings.weekStartsSunday");
}
function updateFocusButton(isActive) {
if (!ui.focusBtn) return;
const active = typeof isActive === "boolean" ? isActive : focusMode && focusMode.isActive();
- ui.focusBtn.textContent = active ? "Exit focus" : "Focus";
+ ui.focusBtn.textContent = t(active ? "btn.exitFocus" : "btn.focus");
ui.focusBtn.setAttribute("aria-pressed", active ? "true" : "false");
}
@@ -742,9 +689,9 @@ function updateLockUI() {
const isLocked = lockState.encrypted && !lockState.unlocked;
if (ui.lockBtn) {
if (lockState.encrypted) {
- ui.lockBtn.textContent = isLocked ? "Unlock" : "Remove lock";
+ ui.lockBtn.textContent = t(isLocked ? "btn.unlock" : "btn.removeLock");
} else {
- ui.lockBtn.textContent = "Lock";
+ ui.lockBtn.textContent = t("btn.lock");
}
}
if (ui.lockedOverlay) {
@@ -756,6 +703,79 @@ function updateLockUI() {
});
}
+function initLanguageDropdown() {
+ if (!ui.langBtn || !ui.langList) return;
+
+ import("./modules/i18n.js").then(({ SUPPORTED_LANGUAGES }) => {
+ ui.langList.innerHTML = "";
+ SUPPORTED_LANGUAGES.forEach((lang) => {
+ const li = document.createElement("li");
+ li.className = "dropdown-item";
+ li.dataset.lang = lang.code;
+ li.innerHTML = `
+ <span>${t(lang.nameKey)}</span>
+ <i class="fa-solid fa-check check-icon"></i>
+ `;
+ li.addEventListener("click", () => {
+ setLanguage(lang.code);
+ updateLanguageUI();
+ closeLanguageDropdown();
+ });
+ ui.langList.appendChild(li);
+ });
+ updateLanguageUI();
+ });
+
+ ui.langBtn.addEventListener("click", (e) => {
+ e.stopPropagation();
+ toggleLanguageDropdown();
+ });
+
+ document.addEventListener("click", (e) => {
+ if (ui.langDropdown && !ui.langDropdown.classList.contains("hidden") && !ui.langDropdown.contains(e.target)) {
+ closeLanguageDropdown();
+ }
+ });
+}
+
+function toggleLanguageDropdown() {
+ if (!ui.langDropdown) return;
+ const isHidden = ui.langDropdown.classList.contains("hidden");
+ if (isHidden) {
+ ui.langDropdown.classList.remove("hidden");
+ ui.langBtn.setAttribute("aria-expanded", "true");
+ } else {
+ closeLanguageDropdown();
+ }
+}
+
+function closeLanguageDropdown() {
+ if (ui.langDropdown) {
+ ui.langDropdown.classList.add("hidden");
+ ui.langBtn.setAttribute("aria-expanded", "false");
+ }
+}
+
+function updateLanguageUI() {
+ if (!ui.currentLang || !ui.langList) return;
+ const langCode = getCurrentLanguage();
+ ui.currentLang.textContent = t(`lang.${langCode}`);
+
+ ui.langList.querySelectorAll(".dropdown-item").forEach((item) => {
+ item.classList.toggle("active", item.dataset.lang === langCode);
+ });
+
+ // Re-translate components
+ updateTheme();
+ updateWeekStartLabel();
+ updateLockUI();
+ updateFocusButton();
+ render();
+ if (focusMode && focusMode.isActive()) {
+ focusMode.tick();
+ }
+}
+
function groupOccurrences(occurrences) {
const map = new Map();
occurrences.forEach((occ) => {
@@ -773,7 +793,7 @@ function groupOccurrences(occurrences) {
function decorateOccurrences(occurrences) {
return occurrences.map((occ) => {
const color = state.c[occ.colorIndex] || DEFAULT_COLORS[0];
- const timeLabel = occ.isAllDay ? "All day" : formatTime(new Date(occ.start));
+ const timeLabel = occ.isAllDay ? t("calendar.allDay") : formatTime(new Date(occ.start));
return { ...occ, color, timeLabel };
});
}
@@ -781,6 +801,7 @@ function decorateOccurrences(occurrences) {
function render() {
updateTheme();
updateWeekStartLabel();
+ // Dropdown UI is updated via updateLanguageUI which is called separately
if (ui.titleInput && document.activeElement !== ui.titleInput) {
ui.titleInput.value = state.t;
}
@@ -911,7 +932,7 @@ function renderEventList() {
if (!list.length) {
const empty = document.createElement("div");
empty.className = "event-item";
- empty.textContent = "No events yet.";
+ empty.textContent = t("calendar.noEvents");
ui.eventList.appendChild(empty);
return;
}
@@ -928,7 +949,7 @@ function renderEventList() {
title.textContent = event.title;
const time = document.createElement("div");
time.className = "event-time";
- time.textContent = event.isAllDay ? "All day" : `${event.timeLabel}`;
+ time.textContent = event.timeLabel;
left.appendChild(title);
left.appendChild(time);
@@ -943,29 +964,29 @@ function renderEventList() {
});
}
-function handleSelectDay(date) {
- selectedDate = startOfDay(date);
- if (currentView === "month") {
- if (ui.calendarGrid) {
- const previous = ui.calendarGrid.querySelector(".day-cell.is-selected");
- if (previous) previous.classList.remove("is-selected");
- const key = formatDateKey(selectedDate);
- const next = ui.calendarGrid.querySelector(`.day-cell[data-date="${key}"]`);
- if (next) next.classList.add("is-selected");
- }
- renderEventList();
- return;
- }
-
- viewDate = startOfDay(date);
- render();
-}
+function handleSelectDay(date) {
+ selectedDate = startOfDay(date);
+ if (currentView === "month") {
+ if (ui.calendarGrid) {
+ const previous = ui.calendarGrid.querySelector(".day-cell.is-selected");
+ if (previous) previous.classList.remove("is-selected");
+ const key = formatDateKey(selectedDate);
+ const next = ui.calendarGrid.querySelector(`.day-cell[data-date="${key}"]`);
+ if (next) next.classList.add("is-selected");
+ }
+ renderEventList();
+ return;
+ }
+
+ viewDate = startOfDay(date);
+ render();
+}
function openEventModal({ index = null, date = null } = {}) {
if (!ui.eventModal) return;
editingIndex = index;
const isEditing = typeof index === "number";
- ui.eventModalTitle.textContent = isEditing ? "Edit event" : "Add event";
+ ui.eventModalTitle.textContent = t(isEditing ? "modal.editEvent" : "modal.addEvent");
ui.eventDelete.classList.toggle("hidden", !isEditing);
const baseDate = date || selectedDate;
@@ -1082,7 +1103,7 @@ function saveEvent(event) {
function deleteEvent() {
if (typeof editingIndex !== "number") return;
- const confirmed = window.confirm("Delete this event?");
+ const confirmed = window.confirm(t("confirm.deleteEvent"));
if (!confirmed) return;
state.e.splice(editingIndex, 1);
editingIndex = null;
@@ -1126,14 +1147,14 @@ function submitPassword() {
if (!passwordResolver) return;
const value = ui.passwordInput.value.trim();
if (!value) {
- ui.passwordError.textContent = "Password is required.";
+ ui.passwordError.textContent = t("password.required");
ui.passwordError.classList.remove("hidden");
return;
}
if (passwordMode === "set") {
if (value !== ui.passwordConfirm.value.trim()) {
- ui.passwordError.textContent = "Passwords do not match.";
+ ui.passwordError.textContent = t("password.mismatch");
ui.passwordError.classList.remove("hidden");
return;
}
@@ -1151,36 +1172,36 @@ async function handleLockAction() {
}
if (lockState.encrypted && lockState.unlocked) {
- const confirmed = window.confirm("Remove password protection? This will store data unencrypted in the URL.");
+ const confirmed = window.confirm(t("confirm.removeLock"));
if (!confirmed) return;
password = null;
lockState = { encrypted: false, unlocked: true };
await writeStateToHash(state, null);
updateLockUI();
- showToast("Lock removed", "success");
+ showToast(t("toast.lockRemoved"), "success");
return;
}
const value = await openPasswordModal({
mode: "set",
- title: "Set password",
- description: "Add a password so only people with the link and password can read this calendar.",
- submitLabel: "Set password",
+ title: t("modal.setPassword"),
+ description: t("password.setDesc"),
+ submitLabel: t("modal.setPassword"),
});
if (!value) return;
password = value;
lockState = { encrypted: true, unlocked: true };
await writeStateToHash(state, password);
updateLockUI();
- showToast("Calendar locked", "success");
+ showToast(t("toast.calendarLocked"), "success");
}
async function attemptUnlock() {
const value = await openPasswordModal({
mode: "unlock",
- title: "Unlock calendar",
- description: "Enter the password to decrypt this calendar.",
- submitLabel: "Unlock",
+ title: t("modal.unlockCalendar"),
+ description: t("password.unlockDesc"),
+ submitLabel: t("btn.unlock"),
});
if (!value) return;
try {
@@ -1190,9 +1211,9 @@ async function attemptUnlock() {
state = normalizeState(loaded);
applyStoredView();
render();
- showToast("Calendar unlocked", "success");
+ showToast(t("toast.calendarUnlocked"), "success");
} catch (error) {
- showToast("Incorrect password", "error");
+ showToast(t("toast.incorrectPassword"), "error");
lockState = { encrypted: true, unlocked: false };
updateLockUI();
}
@@ -1297,16 +1318,16 @@ async function handleCopyLink() {
if (navigator.clipboard && navigator.clipboard.writeText) {
try {
await navigator.clipboard.writeText(url);
- showToast("Link copied", "success");
+ showToast(t("toast.linkCopied"), "success");
return;
} catch (error) {
// Fallback below
}
}
if (fallbackCopyText(url)) {
- showToast("Link copied", "success");
+ showToast(t("toast.linkCopied"), "success");
} else {
- showToast("Unable to copy link", "error");
+ showToast(t("toast.unableToCopyLink"), "error");
}
}
@@ -1349,9 +1370,9 @@ async function handleCopyJson() {
if (!ui.jsonOutput) return;
try {
await navigator.clipboard.writeText(ui.jsonOutput.value);
- showToast("JSON copied", "success");
+ showToast(t("toast.jsonCopied"), "success");
} catch (error) {
- showToast("Unable to copy JSON", "error");
+ showToast(t("toast.unableToCopyJson"), "error");
}
}
@@ -1359,9 +1380,9 @@ async function handleCopyHash() {
if (!ui.jsonHash) return;
try {
await navigator.clipboard.writeText(ui.jsonHash.value);
- showToast("Hash copied", "success");
+ showToast(t("toast.hashCopied"), "success");
} catch (error) {
- showToast("Unable to copy hash", "error");
+ showToast(t("toast.unableToCopyHash"), "error");
}
}
@@ -1387,7 +1408,7 @@ function handleIcsFile(event) {
const text = String(reader.result || "");
const imported = parseIcs(text);
if (!imported.length) {
- showToast("No events found", "error");
+ showToast(t("toast.noEventsFound"), "error");
return;
}
const colorCount = state.c.length || 1;
@@ -1407,14 +1428,14 @@ function handleIcsFile(event) {
});
scheduleSave();
render();
- showToast("Events imported", "success");
+ showToast(t("toast.eventsImported"), "success");
};
reader.readAsText(file);
event.target.value = "";
}
function handleClearAll() {
- const confirmed = window.confirm("Clear all events? This cannot be undone.");
+ const confirmed = window.confirm(t("confirm.clearAll"));
if (!confirmed) return;
state.e = [];
scheduleSave();
@@ -1422,7 +1443,6 @@ function handleClearAll() {
}
function bindEvents() {
- if (ui.mobileWarningDismiss) ui.mobileWarningDismiss.addEventListener("click", dismissMobileWarning);
if (ui.titleInput) ui.titleInput.addEventListener("input", handleTitleInput);
if (ui.prevMonth) ui.prevMonth.addEventListener("click", handlePrevMonth);
if (ui.nextMonth) ui.nextMonth.addEventListener("click", handleNextMonth);
@@ -1440,6 +1460,7 @@ function bindEvents() {
if (ui.focusBtn) ui.focusBtn.addEventListener("click", handleFocusToggle);
if (ui.weekstartToggle) ui.weekstartToggle.addEventListener("click", handleWeekStartToggle);
if (ui.themeToggle) ui.themeToggle.addEventListener("click", handleThemeToggle);
+ initLanguageDropdown();
if (ui.unlockBtn) ui.unlockBtn.addEventListener("click", attemptUnlock);
if (ui.viewJson) ui.viewJson.addEventListener("click", openJsonModal);
if (ui.exportJson) ui.exportJson.addEventListener("click", handleExportJson);
@@ -1505,15 +1526,15 @@ function initResponsiveFeatures() {
// From Events to Clock
ui.sidePanel.classList.remove("is-active");
ui.tzSidebar.classList.add("is-active");
- ui.mobileSidebarToggle.querySelector("span").textContent = "Clock";
+ ui.mobileSidebarToggle.querySelector("span").textContent = t("label.clock");
} else if (ui.tzSidebar.classList.contains("is-active")) {
// From Clock to Calendar (Close both)
ui.tzSidebar.classList.remove("is-active");
- ui.mobileSidebarToggle.querySelector("span").textContent = "Details";
+ ui.mobileSidebarToggle.querySelector("span").textContent = t("label.details");
} else {
// From Calendar to Events
ui.sidePanel.classList.add("is-active");
- ui.mobileSidebarToggle.querySelector("span").textContent = "Events";
+ ui.mobileSidebarToggle.querySelector("span").textContent = t("label.events");
}
});
}
@@ -1521,14 +1542,14 @@ function initResponsiveFeatures() {
if (ui.sidePanelClose) {
ui.sidePanelClose.addEventListener("click", () => {
ui.sidePanel.classList.remove("is-active");
- if (ui.mobileSidebarToggle) ui.mobileSidebarToggle.querySelector("span").textContent = "Details";
+ if (ui.mobileSidebarToggle) ui.mobileSidebarToggle.querySelector("span").textContent = t("label.details");
});
}
if (ui.tzSidebarClose) {
ui.tzSidebarClose.addEventListener("click", () => {
ui.tzSidebar.classList.remove("is-active");
- if (ui.mobileSidebarToggle) ui.mobileSidebarToggle.querySelector("span").textContent = "Details";
+ if (ui.mobileSidebarToggle) ui.mobileSidebarToggle.querySelector("span").textContent = t("label.details");
});
}
}
@@ -1547,7 +1568,6 @@ async function init() {
onToggle: updateFocusButton,
});
bindEvents();
- initMobileWarning();
initResponsiveFeatures();
await loadStateFromHash();
if (!isEncryptedHash() && !hasStoredData() && window.location.hash) {
diff --git a/styles-i18n.css b/styles-i18n.css
new file mode 100644
index 0000000..f1e6be8
--- /dev/null
+++ b/styles-i18n.css
@@ -0,0 +1,243 @@
+/* --- Localization Improvements --- */
+/* Ensure UI is EXACTLY the same across all languages */
+
+:root {
+ /* Flexible spacing variables - easy to override per language */
+ --ui-gap: 8px;
+ --panel-gap: 12px;
+ --btn-px: 14px;
+ --btn-py: 7px;
+ --font-line-height: 1.2;
+}
+
+/* Apply variables to broad components */
+button {
+ min-width: 0;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ padding: var(--btn-py) var(--btn-px);
+ line-height: var(--font-line-height);
+}
+
+/* Language-specific overrides */
+body[lang="si"] {
+ --font-line-height: 1.4; /* Sinhala needs more vertical space */
+ --ui-gap: 10px; /* Slighty more breathing room for complex characters */
+}
+
+/* Enforce consistent button heights for settings buttons only */
+.panel-actions button {
+ min-height: 34px;
+ max-height: 34px;
+ line-height: 1.2;
+}
+
+/* Mobile layout - EXACT same structure as English */
+@media (max-width: 720px) {
+ .panel-header {
+ gap: 12px;
+ }
+
+ .panel-actions {
+ display: grid !important;
+ grid-template-columns: 1fr 1fr;
+ width: 100%;
+ gap: 8px;
+ row-gap: 8px;
+ }
+
+ .panel-actions button {
+ width: 100%;
+ justify-content: center;
+ padding: 7px 8px;
+ font-size: 0.78rem;
+ min-width: 0;
+ min-height: 34px;
+ max-height: 34px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ box-sizing: border-box;
+ }
+
+ /* Details button - full width */
+ #mobile-sidebar-toggle {
+ grid-column: span 2;
+ }
+
+ /* Reduce spacing in top bar */
+ .top-actions {
+ gap: 6px;
+ }
+
+ .top-actions button {
+ padding: 6px 10px;
+ font-size: 0.8rem;
+ }
+}
+
+/* Tablet - maintain single row layout */
+@media (min-width: 721px) and (max-width: 1024px) {
+ .panel-actions {
+ display: flex !important;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ gap: 8px;
+ }
+
+ .panel-actions button {
+ padding: 7px 10px;
+ font-size: 0.82rem;
+ min-width: 0;
+ flex: 1 1 auto;
+ min-height: 34px;
+ max-height: 34px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .top-actions button {
+ padding: 6px 11px;
+ font-size: 0.82rem;
+ }
+}
+
+/* Desktop - maintain same layout as English */
+@media (min-width: 1025px) {
+ .panel-actions {
+ display: flex !important;
+ flex-direction: row;
+ gap: 8px;
+ }
+
+ .panel-actions button {
+ padding: 7px 14px;
+ min-width: 0;
+ max-width: 220px;
+ min-height: 34px;
+ max-height: 34px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+}
+
+/* Ensure all text content doesn't break layout */
+.panel-actions button,
+.top-actions button,
+.view-toggle button {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+}
+
+/* Countdown widget - prevent layout shift */
+.countdown-container {
+ min-height: 60px;
+}
+
+.countdown-title,
+.countdown-meta {
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+/* --- Dropdown Premium Styling --- */
+.dropdown-container {
+ position: relative;
+ display: inline-block;
+}
+
+.dropdown-trigger {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ padding: 7px 12px;
+ cursor: pointer;
+ color: var(--text);
+ font-size: 0.85rem;
+ transition: all 0.2s ease;
+ min-height: 34px;
+}
+
+.dropdown-trigger:hover {
+ border-color: var(--accent);
+ background: var(--hover);
+}
+
+.dropdown-trigger .fa-chevron-down {
+ font-size: 0.7rem;
+ opacity: 0.7;
+}
+
+.dropdown-menu {
+ position: absolute;
+ top: calc(100% + 5px);
+ right: 0;
+ min-width: 160px;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ box-shadow: 0 10px 25px rgba(0,0,0,0.15);
+ z-index: 1000;
+ overflow: hidden;
+ animation: dropdownIn 0.2s ease-out;
+}
+
+@keyframes dropdownIn {
+ from { opacity: 0; transform: translateY(-10px); }
+ to { opacity: 1; transform: translateY(0); }
+}
+
+.dropdown-list {
+ list-style: none;
+ padding: 5px 0;
+ margin: 0;
+}
+
+.dropdown-item {
+ padding: 8px 15px;
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ font-size: 0.9rem;
+ transition: background 0.15s ease;
+ color: var(--text);
+}
+
+.dropdown-item:hover {
+ background: var(--hover);
+}
+
+.dropdown-item.active {
+ color: var(--accent);
+ font-weight: 600;
+}
+
+.dropdown-item .check-icon {
+ font-size: 0.8rem;
+ display: none;
+}
+
+.dropdown-item.active .check-icon {
+ display: block;
+}
+
+/* Glassmorphism for dark mode */
+body[data-theme="dark"] .dropdown-menu {
+ background: rgba(45, 45, 45, 0.95);
+ backdrop-filter: blur(10px);
+}
+
+.hidden {
+ display: none !important;
+}
+
diff --git a/styles-logo.css b/styles-logo.css
new file mode 100644
index 0000000..4ea08ac
--- /dev/null
+++ b/styles-logo.css
@@ -0,0 +1,23 @@
+/* Logo Link Styling */
+.logo-link {
+ text-decoration: none;
+ display: inline-block;
+}
+
+.brand-mark {
+ transition: transform 0.2s ease;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.brand-mark:hover {
+ transform: scale(1.05);
+}
+
+.logo-img {
+ width: 40px;
+ height: 40px;
+ display: block;
+ object-fit: contain;
+}