From edd88724038e9a1a25f83cc4514cae8ee6cf4bb4 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Wed, 14 Oct 2020 19:04:02 +0100 Subject: [PATCH] Add translation support for custom background colour disabled text --- src/components/modals/Settings.jsx | 2 +- .../modals/settings/sections/BackgroundSettings.jsx | 8 ++++---- src/modules/settingsFunctions.js | 4 ++-- src/translations/en.json | 6 +++--- src/translations/fr.json | 3 +-- src/translations/ru.json | 3 +-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/components/modals/Settings.jsx b/src/components/modals/Settings.jsx index 62ef75f3..de0422fe 100644 --- a/src/components/modals/Settings.jsx +++ b/src/components/modals/Settings.jsx @@ -106,7 +106,7 @@ export default class Settings extends React.PureComponent { - + diff --git a/src/components/modals/settings/sections/BackgroundSettings.jsx b/src/components/modals/settings/sections/BackgroundSettings.jsx index 0a5ad236..6f3c575a 100644 --- a/src/components/modals/settings/sections/BackgroundSettings.jsx +++ b/src/components/modals/settings/sections/BackgroundSettings.jsx @@ -3,7 +3,7 @@ import { toast } from 'react-toastify'; import Checkbox from '../Checkbox'; export default class BackgroundSettings extends React.PureComponent { - DefaultGradientSettings = { "angle": "180", "gradient": [{ "colour": "Disabled", "stop": 0 }], "type": "linear" }; + DefaultGradientSettings = { "angle": "180", "gradient": [{ "colour": this.props.language.background.disabled, "stop": 0 }], "type": "linear" }; constructor(...args) { super(...args); @@ -118,14 +118,14 @@ export default class BackgroundSettings extends React.PureComponent { } currentGradientSettings = () => { - if (typeof this.state.gradientSettings === 'object' && this.state.gradientSettings.gradient.every(g => g.colour !== 'Disabled')) { + if (typeof this.state.gradientSettings === 'object' && this.state.gradientSettings.gradient.every(g => g.colour !== this.props.language.background.disabled)) { const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); return JSON.stringify({ ...this.state.gradientSettings, gradient: [...this.state.gradientSettings.gradient.map(g => { return { ...g, stop: clampNumber(+g.stop, 0, 100) } })].sort((a, b) => (a.stop > b.stop) ? 1 : -1) }); } - return 'Disabled'; + return this.props.language.background.disabled; } render() { @@ -146,7 +146,7 @@ export default class BackgroundSettings extends React.PureComponent { colourSettings = (
{gradientInputs} - {this.state.gradientSettings.gradient[0].colour !== 'Disabled' ? () : null} + {this.state.gradientSettings.gradient[0].colour !== this.props.language.background.disabled ? () : null}
); } diff --git a/src/modules/settingsFunctions.js b/src/modules/settingsFunctions.js index 5817a007..dd3eddc6 100644 --- a/src/modules/settingsFunctions.js +++ b/src/modules/settingsFunctions.js @@ -47,12 +47,12 @@ export default class SettingsFunctions { } } - static saveStuff() { + static saveStuff(hexDisabled) { localStorage.setItem('blur', document.getElementById('blurRange').value); // this is better than inline onChange for performance localStorage.setItem('brightness', document.getElementById('brightnessRange').value); localStorage.setItem('greetingName', document.getElementById('greetingName').value); localStorage.setItem('customBackground', document.getElementById('customBackground').value); - if (document.getElementById('customBackgroundHex').value !== 'Disabled') { + if (document.getElementById('customBackgroundHex').value !== hexDisabled) { localStorage.setItem('customBackgroundColour', document.getElementById('customBackgroundHex').value); } if (document.getElementById('searchEngineInput').enabled === 'true') { diff --git a/src/translations/en.json b/src/translations/en.json index 6733a23e..498bfc51 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -48,7 +48,8 @@ "addcolour": "Add colour", "favourite": "Favourite", "view": "View", - "refresh": "Refresh" + "refresh": "Refresh", + "disabled": "Disabled" }, "searchbar": { "title": "Search Bar", @@ -67,8 +68,7 @@ "apply": "Apply", "reset": "Reset", "import": "Import", - "export": "Export", - "imported_settings": "Imported settings" + "export": "Export" }, "update": { "title": "Update", diff --git a/src/translations/fr.json b/src/translations/fr.json index 50e700a4..3b1aacd7 100644 --- a/src/translations/fr.json +++ b/src/translations/fr.json @@ -68,8 +68,7 @@ "apply": "Appliquer", "reset": "Réinitialiser", "import": "Importer", - "export": "Exporter", - "imported_settings": "Paramètres importés" + "export": "Exporter" }, "update": { "title": "Mise à jour", diff --git a/src/translations/ru.json b/src/translations/ru.json index f177a2f2..087ad5b3 100644 --- a/src/translations/ru.json +++ b/src/translations/ru.json @@ -60,8 +60,7 @@ "apply": "Применить", "reset": "Сбросить", "import": "Импорт", - "export": "Экспорт", - "imported_settings": "Импортированные настройки" + "export": "Экспорт" }, "update": { "title": "Обновление",