diff --git a/src/features/misc/sections/Language.jsx b/src/features/misc/sections/Language.jsx index 77d4bfe4..1867fff6 100644 --- a/src/features/misc/sections/Language.jsx +++ b/src/features/misc/sections/Language.jsx @@ -4,7 +4,7 @@ import { useT, useTranslation } from 'contexts/TranslationContext'; import { MdOutlineOpenInNew, MdSearch, MdComputer } from 'react-icons/md'; import { TextField, InputAdornment } from '@mui/material'; -import { Radio } from 'components/Form/Settings'; +import { Radio, Checkbox } from 'components/Form/Settings'; import languages from '@/i18n/languages.json'; @@ -100,6 +100,13 @@ const LanguageOptions = () => { +
+ +
{ const StatsElement = ({ title, value }) => (
{title} - {value} + {formatNumber(value)}
); diff --git a/src/features/time/Clock.jsx b/src/features/time/Clock.jsx index 04694305..99a40bea 100644 --- a/src/features/time/Clock.jsx +++ b/src/features/time/Clock.jsx @@ -1,6 +1,7 @@ import { useState, useEffect, useRef } from 'react'; import { convertTimezone } from 'utils/date'; +import { formatPercentage } from 'utils/formatNumber'; import { AnalogClock } from './components/AnalogClock'; import { VerticalClock } from './components/VerticalClock'; import EventBus from 'utils/eventbus'; @@ -33,7 +34,7 @@ const Clock = () => { switch (localStorage.getItem('timeType')) { case 'percentageComplete': - setTime((now.getHours() / 24).toFixed(2).replace('0.', '') + '%'); + setTime(formatPercentage(now.getHours() / 24)); setAmpm(''); break; case 'analogue': diff --git a/src/i18n/locales/ar.json b/src/i18n/locales/ar.json index 04345b32..f0a9491d 100644 --- a/src/i18n/locales/ar.json +++ b/src/i18n/locales/ar.json @@ -479,7 +479,8 @@ "quote": "لغة الاقتباس", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "سجل التغييرات", diff --git a/src/i18n/locales/arz.json b/src/i18n/locales/arz.json index a45b70c7..5a817731 100644 --- a/src/i18n/locales/arz.json +++ b/src/i18n/locales/arz.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/az.json b/src/i18n/locales/az.json index 9cafbab9..f120de2d 100644 --- a/src/i18n/locales/az.json +++ b/src/i18n/locales/az.json @@ -479,7 +479,8 @@ "quote": "Sitat dili", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Dəyişikliklər Siyahısı", diff --git a/src/i18n/locales/azb.json b/src/i18n/locales/azb.json index 802c85c7..d0d9c1bc 100644 --- a/src/i18n/locales/azb.json +++ b/src/i18n/locales/azb.json @@ -479,7 +479,8 @@ "quote": "Sitat dili", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Dəyişikliklər Siyahısı", diff --git a/src/i18n/locales/bn.json b/src/i18n/locales/bn.json index 02a396d2..5575fcd3 100644 --- a/src/i18n/locales/bn.json +++ b/src/i18n/locales/bn.json @@ -479,7 +479,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/de_DE.json b/src/i18n/locales/de_DE.json index 23fd79e7..62ff3101 100644 --- a/src/i18n/locales/de_DE.json +++ b/src/i18n/locales/de_DE.json @@ -479,7 +479,8 @@ "quote": "Zitat-Sprache", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Änderungen", diff --git a/src/i18n/locales/el.json b/src/i18n/locales/el.json index c78113ca..3355e4a0 100644 --- a/src/i18n/locales/el.json +++ b/src/i18n/locales/el.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/en_GB.json b/src/i18n/locales/en_GB.json index 59e60c7e..104fc94b 100644 --- a/src/i18n/locales/en_GB.json +++ b/src/i18n/locales/en_GB.json @@ -479,7 +479,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/en_US.json b/src/i18n/locales/en_US.json index 43b8014f..decee5b9 100644 --- a/src/i18n/locales/en_US.json +++ b/src/i18n/locales/en_US.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index c49a9d6c..2261f0da 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -479,7 +479,8 @@ "quote": "Idioma de las citas", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Registro de cambios", diff --git a/src/i18n/locales/es_419.json b/src/i18n/locales/es_419.json index ef2b7152..d602487e 100644 --- a/src/i18n/locales/es_419.json +++ b/src/i18n/locales/es_419.json @@ -479,7 +479,8 @@ "quote": "Idioma de las citaciones", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Registro de cambios", diff --git a/src/i18n/locales/et.json b/src/i18n/locales/et.json index 1d69effe..d0022be6 100644 --- a/src/i18n/locales/et.json +++ b/src/i18n/locales/et.json @@ -479,7 +479,8 @@ "quote": "Tsitaadi keel", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Muudatuste logi", diff --git a/src/i18n/locales/fa.json b/src/i18n/locales/fa.json index b54f2bd1..70770873 100644 --- a/src/i18n/locales/fa.json +++ b/src/i18n/locales/fa.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index f19ac842..459bb1d2 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -479,7 +479,8 @@ "quote": "Langue des citations", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Journal des modifications", diff --git a/src/i18n/locales/hu.json b/src/i18n/locales/hu.json index 7efbf6c9..a3a2653d 100644 --- a/src/i18n/locales/hu.json +++ b/src/i18n/locales/hu.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/id_ID.json b/src/i18n/locales/id_ID.json index 77cc1284..d6031c4e 100644 --- a/src/i18n/locales/id_ID.json +++ b/src/i18n/locales/id_ID.json @@ -479,7 +479,8 @@ "quote": "Bahasa untuk kutipan", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Changelog", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index d9e2d88a..718c256e 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/lt.json b/src/i18n/locales/lt.json index 3caa6207..e6e81b91 100644 --- a/src/i18n/locales/lt.json +++ b/src/i18n/locales/lt.json @@ -479,7 +479,8 @@ "quote": "Citatų kalba", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Pakeitimų žurnalas", diff --git a/src/i18n/locales/lv.json b/src/i18n/locales/lv.json index c7635b44..87a03734 100644 --- a/src/i18n/locales/lv.json +++ b/src/i18n/locales/lv.json @@ -479,7 +479,8 @@ "quote": "Citātu valoda", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Izmaiņu žurnāls", diff --git a/src/i18n/locales/nl.json b/src/i18n/locales/nl.json index 8734da98..1ee81fc8 100644 --- a/src/i18n/locales/nl.json +++ b/src/i18n/locales/nl.json @@ -479,7 +479,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/no.json b/src/i18n/locales/no.json index 30aa1e12..9ead966b 100644 --- a/src/i18n/locales/no.json +++ b/src/i18n/locales/no.json @@ -479,7 +479,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/peo.json b/src/i18n/locales/peo.json index 3b0d8fd1..bc4b29ab 100644 --- a/src/i18n/locales/peo.json +++ b/src/i18n/locales/peo.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 5cc29cdb..252897eb 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -479,7 +479,8 @@ "quote": "Idioma das citações", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Registo de alterações", diff --git a/src/i18n/locales/pt_BR.json b/src/i18n/locales/pt_BR.json index bc63ea57..3dc2b2fe 100644 --- a/src/i18n/locales/pt_BR.json +++ b/src/i18n/locales/pt_BR.json @@ -479,7 +479,8 @@ "quote": "Idioma das citações", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Registo de alterações", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index 0f54e3bb..0ff0b84e 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -479,7 +479,8 @@ "quote": "Язык цитат", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Журнал изменений", diff --git a/src/i18n/locales/sl.json b/src/i18n/locales/sl.json index 82ab92f7..20bf71c8 100644 --- a/src/i18n/locales/sl.json +++ b/src/i18n/locales/sl.json @@ -479,7 +479,8 @@ "quote": "Jezik citata", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Dnevnik sprememb", diff --git a/src/i18n/locales/sv.json b/src/i18n/locales/sv.json index 0f44b90a..baa6e9e9 100644 --- a/src/i18n/locales/sv.json +++ b/src/i18n/locales/sv.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/ta.json b/src/i18n/locales/ta.json index c4ccfebc..d2264dfe 100644 --- a/src/i18n/locales/ta.json +++ b/src/i18n/locales/ta.json @@ -479,7 +479,8 @@ "quote": "மேற்கோள் மொழி", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "பதிவை மாற்றவும்", diff --git a/src/i18n/locales/tr_TR.json b/src/i18n/locales/tr_TR.json index 401829f0..4d382cde 100644 --- a/src/i18n/locales/tr_TR.json +++ b/src/i18n/locales/tr_TR.json @@ -479,7 +479,8 @@ "quote": "Alıntı dili", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Değişiklik Günlüğü", diff --git a/src/i18n/locales/uk.json b/src/i18n/locales/uk.json index a25f5d76..55276f95 100644 --- a/src/i18n/locales/uk.json +++ b/src/i18n/locales/uk.json @@ -479,7 +479,8 @@ "quote": "Мова цитат", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Журнал змін", diff --git a/src/i18n/locales/vi.json b/src/i18n/locales/vi.json index 39baba9f..3a998d13 100644 --- a/src/i18n/locales/vi.json +++ b/src/i18n/locales/vi.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/i18n/locales/zh_CN.json b/src/i18n/locales/zh_CN.json index 1e5d9c6e..11df41d3 100644 --- a/src/i18n/locales/zh_CN.json +++ b/src/i18n/locales/zh_CN.json @@ -479,7 +479,8 @@ "quote": "名言语言", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "更新日志", diff --git a/src/i18n/locales/zh_Hant.json b/src/i18n/locales/zh_Hant.json index 33e9d1e2..77a7e34d 100644 --- a/src/i18n/locales/zh_Hant.json +++ b/src/i18n/locales/zh_Hant.json @@ -487,7 +487,8 @@ "quote": "Quote language", "search": "Search languages...", "current": "Current", - "use_system": "Use system language" + "use_system": "Use system language", + "locale_formatting": "Format numbers for your language" }, "changelog": { "title": "Change Log", diff --git a/src/lib/translations.js b/src/lib/translations.js index ab519a56..ea0896c5 100644 --- a/src/lib/translations.js +++ b/src/lib/translations.js @@ -41,7 +41,7 @@ import zh_Hant from 'translations/zh_Hant.json'; * @returns The i18n object. */ export function initTranslations(locale) { - const i18n = new I18n(locale, { + const i18n = new I18n('en_GB', { ar, arz, az, diff --git a/src/utils/data/default_settings.json b/src/utils/data/default_settings.json index ec3ed152..becaf659 100644 --- a/src/utils/data/default_settings.json +++ b/src/utils/data/default_settings.json @@ -235,6 +235,10 @@ "name": "statsData", "value": "{}" }, + { + "name": "localeFormatting", + "value": false + }, { "name": "offlineMode", "value": false diff --git a/src/utils/formatNumber.js b/src/utils/formatNumber.js new file mode 100644 index 00000000..1312ed5c --- /dev/null +++ b/src/utils/formatNumber.js @@ -0,0 +1,42 @@ +/** + * Convert language code from Mue format (en_US) to locale format (en-US) + */ +export function getLocaleCode() { + return localStorage.getItem('language')?.replace(/_/g, '-') || 'en-GB'; +} + +/** + * Format number with locale awareness (if enabled) + * @param {number} value - The number to format + * @param {Intl.NumberFormatOptions} options - Optional Intl.NumberFormat options + * @returns {string} Formatted number string + */ +export function formatNumber(value, options = {}) { + if (localStorage.getItem('localeFormatting') !== 'true') { + return String(value); + } + try { + return new Intl.NumberFormat(getLocaleCode(), options).format(value); + } catch { + return String(value); + } +} + +/** + * Format percentage with locale awareness (if enabled) + * @param {number} value - The decimal value (e.g., 0.45 for 45%) + * @returns {string} Formatted percentage string + */ +export function formatPercentage(value) { + if (localStorage.getItem('localeFormatting') !== 'true') { + return Math.round(value * 100) + '%'; + } + try { + return new Intl.NumberFormat(getLocaleCode(), { + style: 'percent', + maximumFractionDigits: 0, + }).format(value); + } catch { + return Math.round(value * 100) + '%'; + } +}