@@ -85,25 +88,23 @@ export default class Changelog extends PureComponent {
);
};
- if (navigator.onLine === false || this.offlineMode) {
- const language = window.language.modals.main.marketplace;
-
+ if (navigator.onLine === false || this.offlineMode) {
return errorMessage(<>
-
{language.offline.title}
-
{language.offline.description}
+
{getMessage(languagecode, 'modals.main.marketplace.offline.title')}
+
{getMessage(languagecode, 'modals.main.marketplace.offline.description')}
>);
}
if (!this.state.title) {
- return errorMessage(
{window.language.modals.main.loading}
);
+ return errorMessage(
{getMessage(languagecode, 'modals.main.loading')}
);
}
return (
{this.state.title}
{this.state.author} • {this.state.date}
- {this.state.image ?

: null}
+ {this.state.image ?

: null}
this.setState({ showLightbox: false })} isOpen={this.state.showLightbox} className='Modal lightboxmodal' overlayClassName='Overlay resetoverlay' ariaHideApp={false}>
this.setState({ showLightbox: false })} img={this.state.lightboxImg}/>
diff --git a/src/components/modals/main/settings/sections/Experimental.jsx b/src/components/modals/main/settings/sections/Experimental.jsx
index ba9d2d7f..153cd4b1 100644
--- a/src/components/modals/main/settings/sections/Experimental.jsx
+++ b/src/components/modals/main/settings/sections/Experimental.jsx
@@ -1,17 +1,18 @@
+import variables from 'modules/variables';
import Checkbox from '../Checkbox';
import Slider from '../Slider';
import EventBus from 'modules/helpers/eventbus';
export default function ExperimentalSettings() {
- const { experimental } = window.language.modals.main.settings.sections;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
return (
<>
- {experimental.title}
- {experimental.warning}
-
- {experimental.developer}
+ {getMessage(languagecode, 'modals.main.settings.sections.experimental.title')}
+ {getMessage(languagecode, 'modals.main.settings.sections.experimental.warning')}
+ {getMessage(languagecode, 'modals.main.settings.sections.experimental.developer')}
diff --git a/src/components/modals/main/settings/sections/Greeting.jsx b/src/components/modals/main/settings/sections/Greeting.jsx
index ef550746..a16b31f3 100644
--- a/src/components/modals/main/settings/sections/Greeting.jsx
+++ b/src/components/modals/main/settings/sections/Greeting.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Checkbox from '../Checkbox';
@@ -11,7 +12,6 @@ export default class GreetingSettings extends PureComponent {
this.state = {
birthday: new Date(localStorage.getItem('birthday')) || new Date()
};
- this.language = window.language.modals.main.settings;
}
changeDate = (e) => {
@@ -23,21 +23,22 @@ export default class GreetingSettings extends PureComponent {
}
render() {
- const { greeting } = this.language.sections;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
return (
<>
- {greeting.title}
-
-
-
-
-
+ {getMessage(languagecode, 'modals.main.settings.sections.greeting.title')}
+
+
+
+
+
- {greeting.birthday}
-
-
- {greeting.birthday_date}
+ {getMessage(languagecode, 'modals.main.settings.sections.greeting.birthday')}
+
+
+ {getMessage(languagecode, 'modals.main.settings.sections.greeting.birthday_date')}
>
);
diff --git a/src/components/modals/main/settings/sections/Keybinds.jsx b/src/components/modals/main/settings/sections/Keybinds.jsx
index e9f08d86..7a95ec6a 100644
--- a/src/components/modals/main/settings/sections/Keybinds.jsx
+++ b/src/components/modals/main/settings/sections/Keybinds.jsx
@@ -1,15 +1,18 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Switch from '../Switch';
import KeybindInput from '../KeybindInput';
export default class KeybindSettings extends PureComponent {
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
+
constructor() {
super();
this.state = {
keybinds: JSON.parse(localStorage.getItem('keybinds')) || {}
};
- this.language = window.language.modals.main.settings;
}
showReminder() {
@@ -19,7 +22,7 @@ export default class KeybindSettings extends PureComponent {
listen(type) {
const currentKeybinds = this.state.keybinds;
- currentKeybinds[type] = this.language.sections.keybinds.recording;
+ currentKeybinds[type] = this.getMessage(this.languagecode, 'modals.main.settings.sections.keybinds.recording');
this.setState({
keybinds: currentKeybinds
});
@@ -72,24 +75,22 @@ export default class KeybindSettings extends PureComponent {
}
render() {
- const { keybinds } = this.language.sections;
-
return (
<>
- {keybinds.title}
-
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
- this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.keybinds.title')}
+
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
+ this.listen(e)} reset={(e) => this.reset(e)} cancel={(e) => this.cancel(e)}/>
>
);
}
diff --git a/src/components/modals/main/settings/sections/Language.jsx b/src/components/modals/main/settings/sections/Language.jsx
index 9e99c2d8..0c2cdd3f 100644
--- a/src/components/modals/main/settings/sections/Language.jsx
+++ b/src/components/modals/main/settings/sections/Language.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Radio from '../Radio';
@@ -5,11 +6,14 @@ import Radio from '../Radio';
const languages = require('modules/languages.json');
export default class BackgroundSettings extends PureComponent {
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
+
constructor() {
super();
this.state = {
quoteLanguages: [{
- name: window.language.modals.main.loading,
+ name: this.getMessage(this.languagecode, 'modals.main.loading'),
value: 'loading'
}]
};
@@ -40,7 +44,7 @@ export default class BackgroundSettings extends PureComponent {
if (navigator.onLine === false || localStorage.getItem('offlineMode') === 'true') {
return this.setState({
quoteLanguages: [{
- name: window.language.modals.main.marketplace.offline.description,
+ name: this.getMessage(this.languagecode, 'modals.main.marketplace.offline.description'),
value: 'loading'
}]
});
@@ -55,13 +59,11 @@ export default class BackgroundSettings extends PureComponent {
}
render() {
- const language = window.language.modals.main.settings.sections.language;
-
return (
<>
- {language.title}
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.language.title')}
- {language.quote}
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.language.quote')}
>
);
diff --git a/src/components/modals/main/settings/sections/Order.jsx b/src/components/modals/main/settings/sections/Order.jsx
index 43043671..2f52dc25 100644
--- a/src/components/modals/main/settings/sections/Order.jsx
+++ b/src/components/modals/main/settings/sections/Order.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import { DragIndicator } from '@material-ui/icons';
import { sortableContainer, sortableElement } from 'react-sortable-hoc';
@@ -5,13 +6,14 @@ import { toast } from 'react-toastify';
import EventBus from 'modules/helpers/eventbus';
-const settings = window.language.modals.main.settings.sections;
+const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+const languagecode = variables.languagecode;
const widget_name = {
- greeting: settings.greeting.title,
- time: settings.time.title,
- quicklinks: settings.quicklinks.title,
- quote: settings.quote.title,
- date: settings.time.date.title
+ greeting: getMessage(languagecode, 'modals.main.settings.sections.greeting.title'),
+ time: getMessage(languagecode, 'modals.main.settings.sections.time.title'),
+ quicklinks: getMessage(languagecode, 'modals.main.settings.sections.quicklinks.title'),
+ quote: getMessage(languagecode, 'modals.main.settings.sections.quote.title'),
+ date: getMessage(languagecode, 'modals.main.settings.sections.greeting.title')
};
const SortableItem = sortableElement(({ value }) => (
@@ -31,7 +33,6 @@ export default class OrderSettings extends PureComponent {
this.state = {
items: JSON.parse(localStorage.getItem('order'))
};
- this.language = window.language.modals.main.settings;
}
// based on https://stackoverflow.com/a/48301905
@@ -65,7 +66,7 @@ export default class OrderSettings extends PureComponent {
items: JSON.parse(localStorage.getItem('order'))
});
- toast(window.language.toasts.reset);
+ toast(getMessage(languagecode, 'toats.reset'));
}
enabled = (setting) => {
@@ -86,8 +87,8 @@ export default class OrderSettings extends PureComponent {
render() {
return (
<>
- {this.language.sections.order.title}
- {this.language.buttons.reset}
+ {getMessage(languagecode, 'modals.main.settings.sections.order.title')}
+ {getMessage(languagecode, 'modals.main.settings.buttons.reset')}
{this.state.items.map((value, index) => {
if (!this.enabled(value)) {
diff --git a/src/components/modals/main/settings/sections/QuickLinks.jsx b/src/components/modals/main/settings/sections/QuickLinks.jsx
index 22cee2fd..a4b50f39 100644
--- a/src/components/modals/main/settings/sections/QuickLinks.jsx
+++ b/src/components/modals/main/settings/sections/QuickLinks.jsx
@@ -1,18 +1,21 @@
+import variables from 'modules/variables';
+
import Switch from '../Switch';
import Checkbox from '../Checkbox';
import Slider from '../Slider';
export default function QuickLinks() {
- const language = window.language.modals.main.settings.sections.quicklinks;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
return (
<>
- {language.title}
-
-
-
-
-
+ {getMessage(languagecode, 'modals.main.settings.sections.quicklinks.title')}
+
+
+
+
+
>
);
}
diff --git a/src/components/modals/main/settings/sections/Quote.jsx b/src/components/modals/main/settings/sections/Quote.jsx
index 4aaf95df..754d3519 100644
--- a/src/components/modals/main/settings/sections/Quote.jsx
+++ b/src/components/modals/main/settings/sections/Quote.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Checkbox from '../Checkbox';
@@ -7,6 +8,9 @@ import Slider from '../Slider';
import Dropdown from '../Dropdown';
export default class QuoteSettings extends PureComponent {
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
+
constructor() {
super();
this.state = {
@@ -16,19 +20,17 @@ export default class QuoteSettings extends PureComponent {
marketplaceType = () => {
if (localStorage.getItem('quote_packs')) {
- return ;
+ return ;
}
}
render() {
- const { quote, background } = window.language.modals.main.settings.sections;
-
let customSettings;
if (this.state.quoteType === 'custom') {
customSettings = (
<>
-
-
+
+
>
);
} else {
@@ -36,14 +38,14 @@ export default class QuoteSettings extends PureComponent {
customSettings = (
<>
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
>
);
@@ -51,21 +53,21 @@ export default class QuoteSettings extends PureComponent {
return (
<>
- {quote.title}
-
-
- this.setState({ quoteType: value })} category='quote'>
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.quote.title')}
+
+
+ this.setState({ quoteType: value })} category='quote'>
{this.marketplaceType()}
-
-
+
+
{customSettings}
-
+
- {quote.buttons.title}
-
-
-
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.quote.buttons.title')}
+
+
+
>
);
}
diff --git a/src/components/modals/main/settings/sections/Search.jsx b/src/components/modals/main/settings/sections/Search.jsx
index 36617ec4..25dbd2f7 100644
--- a/src/components/modals/main/settings/sections/Search.jsx
+++ b/src/components/modals/main/settings/sections/Search.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import { toast } from 'react-toastify';
@@ -12,6 +13,9 @@ const searchEngines = require('components/widgets/search/search_engines.json');
const autocompleteProviders = require('components/widgets/search/autocomplete_providers.json');
export default class SearchSettings extends PureComponent {
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
+
constructor() {
super();
this.state = {
@@ -27,7 +31,7 @@ export default class SearchSettings extends PureComponent {
customValue: ''
});
- toast(window.language.toasts.reset);
+ toast(this.getMessage(this.languagecode, 'toasts.reset'));
}
componentDidMount() {
@@ -67,32 +71,29 @@ export default class SearchSettings extends PureComponent {
}
render() {
- const language = window.language.modals.main.settings;
- const { search } = language.sections;
-
return (
<>
- {search.title}
-
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.search.title')}
+
{/* not supported on firefox */}
{(navigator.userAgent.includes('Chrome') && typeof InstallTrigger === 'undefined') ?
-
+
: null}
-
- this.setSearchEngine(value)}>
+
+ this.setSearchEngine(value)}>
{searchEngines.map((engine) => (
))}
-
+
-
-
+
+
>
);
}
diff --git a/src/components/modals/main/settings/sections/Stats.jsx b/src/components/modals/main/settings/sections/Stats.jsx
index e62445bd..1e078a47 100644
--- a/src/components/modals/main/settings/sections/Stats.jsx
+++ b/src/components/modals/main/settings/sections/Stats.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Switch from '../Switch';
@@ -10,7 +11,6 @@ export default class Stats extends PureComponent {
this.state = {
stats: JSON.parse(localStorage.getItem('statsData')) || {}
};
- this.language = window.language.modals.main.settings.sections.stats;
}
componentDidMount() {
@@ -32,27 +32,30 @@ export default class Stats extends PureComponent {
}
render() {
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
+
if (localStorage.getItem('stats') === 'false') {
return (
<>
- {window.language.modals.main.settings.reminder.title}
- {this.language.warning}
-
+ {getMessage(languagecode, 'modals.main.settings.reminder.title')}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.warning')}
+
>
);
}
return (
<>
- {this.language.title}
- {this.language.sections.tabs_opened}: {this.state.stats['tabs-opened'] || 0}
- {this.language.sections.backgrounds_favourited}: {this.state.stats.feature ? this.state.stats.feature['background-favourite'] || 0 : 0}
- {this.language.sections.backgrounds_downloaded}: {this.state.stats.feature ? this.state.stats.feature['background-download'] || 0 : 0}
- {this.language.sections.quotes_favourited}: {this.state.stats.feature ? this.state.stats.feature['quoted-favourite'] || 0 : 0}
- {this.language.sections.quicklinks_added}: {this.state.stats.feature ? this.state.stats.feature['quicklink-add'] || 0 : 0}
- {this.language.sections.settings_changed}: {this.state.stats.setting ? Object.keys(this.state.stats.setting).length : 0}
- {this.language.sections.addons_installed}: {this.state.stats.marketplace ? this.state.stats.marketplace['install'] : 0}
-
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.title')}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.sections.tabs_opened')}: {this.state.stats['tabs-opened'] || 0}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.sections.backgrounds_favourited')}: {this.state.stats.feature ? this.state.stats.feature['background-favourite'] || 0 : 0}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.sections.backgrounds_downloaded')}: {this.state.stats.feature ? this.state.stats.feature['background-download'] || 0 : 0}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.sections.quotes_favourited')}: {this.state.stats.feature ? this.state.stats.feature['quoted-favourite'] || 0 : 0}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.sections.quicklinks_added')}: {this.state.stats.feature ? this.state.stats.feature['quicklink-add'] || 0 : 0}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.sections.settings_changed')}: {this.state.stats.setting ? Object.keys(this.state.stats.setting).length : 0}
+ {getMessage(languagecode, 'modals.main.settings.sections.stats.sections.addons_installed')}: {this.state.stats.marketplace ? this.state.stats.marketplace['install'] : 0}
+
>
);
}
diff --git a/src/components/modals/main/settings/sections/Time.jsx b/src/components/modals/main/settings/sections/Time.jsx
index a5e079eb..8395ff65 100644
--- a/src/components/modals/main/settings/sections/Time.jsx
+++ b/src/components/modals/main/settings/sections/Time.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Checkbox from '../Checkbox';
@@ -13,43 +14,43 @@ export default class TimeSettings extends PureComponent {
timeType: localStorage.getItem('timeType') || 'digital',
dateType: localStorage.getItem('dateType') || 'long'
};
- this.language = window.language.modals.main.settings;
}
render() {
- const { time } = this.language.sections;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
let timeSettings;
const digitalOptions = [
{
- name: time.digital.twentyfourhour,
+ name: getMessage(languagecode, 'modals.main.settings.sections.time.digital.twentyfourhour'),
value: 'twentyfourhour'
},
{
- name: time.digital.twelvehour,
+ name: getMessage(languagecode, 'modals.main.settings.sections.time.digital.twelvehour'),
value: 'twelvehour'
}
];
const digitalSettings = (
<>
- {time.digital.title}
-
+ {getMessage(languagecode, 'modals.main.settings.sections.time.digital.title')}
+
-
-
+
+
>
);
const analogSettings = (
<>
- {time.analogue.title}
-
-
-
-
-
+ {getMessage(languagecode, 'modals.main.settings.sections.time.analogue.title')}
+
+
+
+
+
>
);
@@ -63,25 +64,25 @@ export default class TimeSettings extends PureComponent {
const longSettings = (
<>
-
-
+
+
>
);
const shortSettings = (
<>
-
+
-
-
-
-
-
+
+
+
+
+
>
);
@@ -94,29 +95,29 @@ export default class TimeSettings extends PureComponent {
return (
<>
- {time.title}
-
- this.setState({ timeType: value })} category='clock'>
-
-
-
+ {getMessage(languagecode, 'modals.main.settings.sections.time.title')}
+
+ this.setState({ timeType: value })} category='clock'>
+
+
+
{timeSettings}
{this.state.timeType !== 'analogue' ?
-
+
: null}
- {time.date.title}
-
- this.setState({ dateType: value })} category='date'>
-
-
+ {getMessage(languagecode, 'modals.main.settings.sections.time.date.title')}
+
+ this.setState({ dateType: value })} category='date'>
+
+
-
-
+
+
{dateSettings}
-
+
>
);
}
diff --git a/src/components/modals/main/settings/sections/Weather.jsx b/src/components/modals/main/settings/sections/Weather.jsx
index d70aaa88..d2d220b1 100644
--- a/src/components/modals/main/settings/sections/Weather.jsx
+++ b/src/components/modals/main/settings/sections/Weather.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Switch from '../Switch';
@@ -11,7 +12,6 @@ export default class TimeSettings extends PureComponent {
this.state = {
location: localStorage.getItem('location') || 'London'
};
- this.language = window.language.modals.main.settings;
}
componentDidUpdate() {
@@ -48,46 +48,47 @@ export default class TimeSettings extends PureComponent {
}
render() {
- const language = window.language.modals.main.settings.sections.weather;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
const tempFormat = [
{
- name: language.temp_format.celsius + ' (°C)',
+ name: getMessage(languagecode, 'modals.main.settings.sections.weather.temp_format.celsius') + ' (°C)',
value: 'celsius'
},
{
- name: language.temp_format.fahrenheit + ' (°F)',
+ name: getMessage(languagecode, 'modals.main.settings.sections.weather.temp_format.fahrenheit') + ' (°F)',
value: 'fahrenheit'
},
{
- name: language.temp_format.kelvin + ' (K)',
+ name: getMessage(languagecode, 'modals.main.settings.sections.weather.temp_format.kelvin') + ' (K)',
value: 'kelvin'
}
];
return (
<>
- {language.title}
-
+ {getMessage(languagecode, 'modals.main.settings.sections.weather.title')}
+
-
-
+
+
- {language.extra_info.title}
-
-
-
-
-
-
-
-
-
-
+ {getMessage(languagecode, 'modals.main.settings.sections.weather.extra_info.title')}
+
+
+
+
+
+
+
+
+
+
>
);
}
diff --git a/src/components/modals/main/settings/sections/background/Background.jsx b/src/components/modals/main/settings/sections/background/Background.jsx
index c0596462..54753675 100644
--- a/src/components/modals/main/settings/sections/background/Background.jsx
+++ b/src/components/modals/main/settings/sections/background/Background.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent, Fragment } from 'react';
import { toast } from 'react-toastify';
@@ -13,14 +14,16 @@ import ColourSettings from './Colour';
import EventBus from 'modules/helpers/eventbus';
export default class BackgroundSettings extends PureComponent {
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
+
constructor() {
super();
this.state = {
customBackground: [''],
backgroundType: localStorage.getItem('backgroundType') || 'api',
- backgroundCategories: [window.language.modals.main.loading]
+ backgroundCategories: [this.getMessage(this.languagecode, 'modals.main.loading')]
};
- this.language = window.language.modals.main.settings;
this.controller = new AbortController();
}
@@ -29,7 +32,7 @@ export default class BackgroundSettings extends PureComponent {
this.setState({
customBackground: ['']
});
- toast(window.language.toasts.reset);
+ toast(this.getMessage(this.languagecode, 'toasts.reset'));
EventBus.dispatch('refresh', 'background');
}
@@ -77,8 +80,8 @@ export default class BackgroundSettings extends PureComponent {
if (customBackground.startsWith('data:video/') || customBackground.endsWith('.mp4') || customBackground.endsWith('.webm') || customBackground.endsWith('.ogg')) {
return (
<>
-
-
+
+
>
);
} else {
@@ -88,7 +91,7 @@ export default class BackgroundSettings extends PureComponent {
marketplaceType = () => {
if (localStorage.getItem('photo_packs')) {
- return ;
+ return ;
}
}
@@ -131,7 +134,7 @@ export default class BackgroundSettings extends PureComponent {
if (navigator.onLine === false || localStorage.getItem('offlineMode') === 'true') {
return this.setState({
- backgroundCategories: [window.language.modals.update.offline.title]
+ backgroundCategories: [this.getMessage(this.languagecode, 'modals.update.offline.title')]
});
}
@@ -144,8 +147,6 @@ export default class BackgroundSettings extends PureComponent {
}
render() {
- const { background } = this.language.sections;
-
let backgroundSettings;
const apiOptions = [
@@ -166,29 +167,29 @@ export default class BackgroundSettings extends PureComponent {
const APISettings = (
<>
-
+
-
+
{this.state.backgroundCategories.map((category) => (
))}
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
>
);
@@ -196,12 +197,12 @@ export default class BackgroundSettings extends PureComponent {
const customSettings = (
<>
- {background.source.custom_background} {this.language.buttons.reset}
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.background.source.custom_background')} {this.getMessage(this.languagecode, 'modals.main.settings.buttons.reset')}
{this.state.customBackground.map((_url, index) => (
{this.state.customBackground.length > 1 ? : null}
this.customBackground(e, true, index)}>
- this.uploadCustombackground(index)}>{background.source.upload}
+ this.uploadCustombackground(index)}>{this.getMessage(this.languagecode, 'modals.main.settings.sections.background.source.ypload')}
{this.videoCustomSettings(index)}
@@ -224,41 +225,41 @@ export default class BackgroundSettings extends PureComponent {
return (
<>
- {background.title}
-
-
-
-
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.background.title')}
+
+
+
+
- {background.source.title}
- this.setState({ backgroundType: value })} category='background'>
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.background.source.title')}
+ this.setState({ backgroundType: value })} category='background'>
{this.marketplaceType()}
-
-
-
+
+
+
{backgroundSettings}
- {background.buttons.title}
-
-
-
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.background.buttons.title')}
+
+
+
- {background.effects.title}
-
-
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.background.effects.title')}
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
>
);
}
diff --git a/src/components/modals/main/settings/sections/background/Colour.jsx b/src/components/modals/main/settings/sections/background/Colour.jsx
index cfbff643..4dd58dba 100644
--- a/src/components/modals/main/settings/sections/background/Colour.jsx
+++ b/src/components/modals/main/settings/sections/background/Colour.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent, Fragment } from 'react';
import { ColorPicker } from 'react-color-gradient-picker';
import { toast } from 'react-toastify';
@@ -11,13 +12,14 @@ import '../../../scss/settings/react-color-picker-gradient-picker-custom-styles.
export default class ColourSettings extends PureComponent {
DefaultGradientSettings = { angle: '180', gradient: [{ colour: '#ffb032', stop: 0 }], type: 'linear' };
GradientPickerInitalState = undefined;
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
constructor() {
super();
this.state = {
gradientSettings: this.DefaultGradientSettings
};
- this.language = window.language.modals.main.settings;
}
resetColour() {
@@ -25,7 +27,7 @@ export default class ColourSettings extends PureComponent {
this.setState({
gradientSettings: this.DefaultGradientSettings
});
- toast(window.language.toasts.reset);
+ toast(this.getMessage(this.languagecode, 'toasts.reset'));
}
initialiseColourPickerState(gradientSettings) {
@@ -109,7 +111,7 @@ export default class ColourSettings extends PureComponent {
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 this.language.sections.background.source.disabled;
+ return this.getMessage(this.languagecode, 'modals.main.settings.sections.background.source.disabled');
}
onColourPickerChange = (attrs, name) => {
@@ -141,8 +143,6 @@ export default class ColourSettings extends PureComponent {
}
render() {
- const { background } = this.language.sections;
-
let colourSettings = null;
if (typeof this.state.gradientSettings === 'object') {
const gradientHasMoreThanOneColour = this.state.gradientSettings.gradient.length > 1;
@@ -175,14 +175,14 @@ export default class ColourSettings extends PureComponent {
colourSettings = (
<>
{gradientInputs}
- {!gradientHasMoreThanOneColour ? (<>
>) : null}
+ {!gradientHasMoreThanOneColour ? (<>
>) : null}
>
);
}
return (
<>
- {background.source.custom_colour} this.resetColour()}>{this.language.buttons.reset}
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.background.source.custom_colour')} this.resetColour()}>{this.getMessage(this.languagecode, 'modals.main.settings.buttons.reset')}
{colourSettings}
>
);
diff --git a/src/components/modals/main/tabs/Addons.jsx b/src/components/modals/main/tabs/Addons.jsx
index 4c21afee..0d598c6e 100644
--- a/src/components/modals/main/tabs/Addons.jsx
+++ b/src/components/modals/main/tabs/Addons.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import Tabs from './backend/Tabs';
import Added from '../marketplace/sections/Added';
@@ -5,13 +6,14 @@ import Sideload from '../marketplace/sections/Sideload';
import Create from '../marketplace/sections/Create';
export default function Addons() {
- const addons = window.language.modals.main.addons;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
return (
-
-
-
+
+
+
);
}
diff --git a/src/components/modals/main/tabs/Marketplace.jsx b/src/components/modals/main/tabs/Marketplace.jsx
index 5a5e8664..9e916225 100644
--- a/src/components/modals/main/tabs/Marketplace.jsx
+++ b/src/components/modals/main/tabs/Marketplace.jsx
@@ -1,15 +1,17 @@
+import variables from 'modules/variables';
import Tabs from './backend/Tabs';
import MarketplaceTab from '../marketplace/sections/Marketplace';
export default function Marketplace() {
- const marketplace = window.language.modals.main.marketplace;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
return (
-
-
-
+
+
+
);
}
diff --git a/src/components/modals/main/tabs/Settings.jsx b/src/components/modals/main/tabs/Settings.jsx
index 53eb53f1..5c1727fb 100644
--- a/src/components/modals/main/tabs/Settings.jsx
+++ b/src/components/modals/main/tabs/Settings.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import Tabs from './backend/Tabs';
import About from '../settings/sections/About';
@@ -18,27 +19,28 @@ import Stats from '../settings/sections/Stats';
import Keybinds from '../settings/sections/Keybinds';
export default function Settings() {
- const { sections } = window.language.modals.main.settings;
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
return (
<>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
>
);
diff --git a/src/components/modals/main/tabs/backend/Tab.jsx b/src/components/modals/main/tabs/backend/Tab.jsx
index 2ad2cd70..730bbf3d 100644
--- a/src/components/modals/main/tabs/backend/Tab.jsx
+++ b/src/components/modals/main/tabs/backend/Tab.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { memo } from 'react';
import {
SettingsRounded as Settings,
@@ -25,6 +26,9 @@ import {
} from '@material-ui/icons';
function Tab({ label, currentTab, onClick, navbarTab }) {
+ const getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ const languagecode = variables.languagecode;
+
let className = 'tab-list-item';
if (currentTab === label) {
className += ' tab-list-active';
@@ -37,44 +41,41 @@ function Tab({ label, currentTab, onClick, navbarTab }) {
}
}
- const settings = window.language.modals.main.settings.sections;
- const { navbar, marketplace, addons } = window.language.modals.main;
-
let icon, divider;
switch (label) {
- case navbar.settings: icon = ; break;
- case navbar.addons: icon = ; break;
- case navbar.marketplace: icon = ; break;
+ case getMessage(languagecode, 'modals.main.navbar.settings'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.navbar.addons'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.navbar.marketplace'): icon = ; break;
- case settings.time.title: icon = ; break;
- case settings.greeting.title: icon = ; break;
- case settings.quote.title: icon =
; break;
- case settings.background.title: icon = ; break;
- case settings.search.title: icon = ; break;
- case settings.weather.title: icon = ; break;
- case settings.quicklinks.title: icon = ; break;
- case settings.appearance.title: icon = ; break;
- case settings.order.title: icon = ; break;
- case settings.language.title: icon = ; divider = true; break;
- case settings.advanced.title: icon = ; break;
- case settings.keybinds.title: icon = ; break;
- case settings.stats.title: icon = ; break;
- case settings.experimental.title: icon = ; divider = true; break;
- case settings.changelog: icon = ; break;
- case settings.about.title: icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.time.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.greeting.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.quote.title'): icon =
; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.background.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.search.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.weather.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.quicklinks.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.appearance.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.order.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.language.title'): icon = ; divider = true; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.advanced.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.keybinds.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.stats.title'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.experimental.title'): icon = ; divider = true; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.changelog'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.settings.sections.about.title'): icon = ; break;
- case addons.added: icon = ; break;
- case addons.sideload: icon = ; break;
- case addons.create.title: icon = ; break;
+ case getMessage(languagecode, 'modals.main.addons.added'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.addons.sideload'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.addons.create.title'): icon = ; break;
- case marketplace.photo_packs: icon = ; break;
- case marketplace.quote_packs: icon =
; break;
- case marketplace.preset_settings: icon = ; break;
+ case getMessage(languagecode, 'modals.main.marketplace.photo_packs'): icon = ; break;
+ case getMessage(languagecode, 'modals.main.marketplace.quote_packs'): icon =
; break;
+ case getMessage(languagecode, 'modals.main.marketplace.preset_settings'): icon = ; break;
default: break;
}
- if (label === settings.experimental.title) {
+ if (label === getMessage(languagecode, 'modals.main.settings.sections.experimental.title')) {
if (localStorage.getItem('experimental') === 'false') {
return
;
}
diff --git a/src/components/modals/main/tabs/backend/Tabs.jsx b/src/components/modals/main/tabs/backend/Tabs.jsx
index cbd79008..99c66ac8 100644
--- a/src/components/modals/main/tabs/backend/Tabs.jsx
+++ b/src/components/modals/main/tabs/backend/Tabs.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import Tab from './Tab';
@@ -25,9 +26,12 @@ export default class Tabs extends PureComponent {
};
render() {
+ const language = variables.language;
+ const languagecode = variables.languagecode;
+
let className = 'sidebar';
let tabClass = 'tab-content';
- let optionsText = ({window.language.modals.main.title}
);
+ let optionsText = ({language.getMessage(languagecode, 'modals.main.title')}
);
if (this.props.navbar) {
className = 'modalNavbar';
diff --git a/src/components/modals/welcome/Welcome.jsx b/src/components/modals/welcome/Welcome.jsx
index 3046fe2f..934d402f 100644
--- a/src/components/modals/welcome/Welcome.jsx
+++ b/src/components/modals/welcome/Welcome.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import EventBus from 'modules/helpers/eventbus';
@@ -8,15 +9,17 @@ import ProgressBar from './ProgressBar';
import './welcome.scss';
export default class WelcomeModal extends PureComponent {
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
+
constructor() {
super();
this.state = {
image: './././icons/undraw_celebration.svg',
currentTab: 0,
finalTab: 4,
- buttonText: window.language.modals.welcome.buttons.next
+ buttonText: this.getMessage(this.languagecode, 'modals.welcome.buttons.next')
};
- this.language = window.language.modals.welcome;
this.images = [
'./././icons/undraw_celebration.svg',
'./././icons/undraw_around_the_world_modified.svg',
@@ -35,18 +38,18 @@ export default class WelcomeModal extends PureComponent {
return this.setState({
currentTab: this.state.currentTab - 1,
image: this.images[this.state.currentTab - 1],
- buttonText: this.language.buttons.next
+ buttonText: this.getMessage(this.languagecode, 'modals.welcome.buttons.next')
});
}
- if (this.state.buttonText === this.language.buttons.close) {
+ if (this.state.buttonText === this.getMessage(this.languagecode, 'modals.welcome.buttons.close')) {
return this.props.modalClose();
}
this.setState({
currentTab: this.state.currentTab + 1,
image: this.images[this.state.currentTab + 1],
- buttonText: (this.state.currentTab !== this.state.finalTab) ? this.language.buttons.next : this.language.buttons.close
+ buttonText: (this.state.currentTab !== this.state.finalTab) ? this.getMessage(this.languagecode, 'modals.welcome.buttons.next') : this.getMessage(this.languagecode, 'modals.welcome.buttons.close')
});
}
@@ -55,7 +58,7 @@ export default class WelcomeModal extends PureComponent {
this.setState({
currentTab: tab,
image: this.images[tab],
- buttonText: (tab !== this.state.finalTab + 1) ? this.language.buttons.next : this.language.buttons.close
+ buttonText: (tab !== this.state.finalTab + 1) ? this.getMessage(this.languagecode, 'modals.welcome.buttons.next') : this.getMessage(this.languagecode, 'modals.welcome.buttons.close')
});
localStorage.setItem('bgtransition', true);
@@ -68,7 +71,7 @@ export default class WelcomeModal extends PureComponent {
this.setState({
currentTab: Number(welcomeTab),
image: this.images[Number(welcomeTab)],
- buttonText: (Number(welcomeTab) !== this.state.finalTab + 1) ? this.language.buttons.next : this.language.buttons.close
+ buttonText: (Number(welcomeTab) !== this.state.finalTab + 1) ? this.getMessage(this.languagecode, 'modals.welcome.buttons.next') : this.getMessage(this.languagecode, 'modals.welcome.buttons.close')
});
}
@@ -97,7 +100,7 @@ export default class WelcomeModal extends PureComponent {
this.switchTab(tab)}/>
- {(this.state.currentTab !== 0) ? : null}
+ {(this.state.currentTab !== 0) ? : null}
diff --git a/src/components/modals/welcome/WelcomeSections.jsx b/src/components/modals/welcome/WelcomeSections.jsx
index 538512a9..6d83b99c 100644
--- a/src/components/modals/welcome/WelcomeSections.jsx
+++ b/src/components/modals/welcome/WelcomeSections.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import { CloudUpload, AutoAwesome, LightMode, DarkMode } from '@material-ui/icons';
@@ -12,6 +13,9 @@ const languages = require('modules/languages.json');
const default_settings = require('modules/default_settings.json');
export default class WelcomeSections extends PureComponent {
+ getMessage = (languagecode, text) => variables.language.getMessage(languagecode, text);
+ languagecode = variables.languagecode;
+
constructor() {
super();
this.state = {
@@ -109,8 +113,8 @@ export default class WelcomeSections extends PureComponent {
const intro = (
<>
-
{language.sections.intro.title}
-
{language.sections.intro.description}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.intro.title')}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.intro.description')}
#shareyourmue

@@ -120,81 +124,78 @@ export default class WelcomeSections extends PureComponent {
const chooseLanguage = (
<>
-
{language.sections.language.title}
-
{language.sections.language.description} GitHub!
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.language.title')}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.language.description')} GitHub!
>
);
-
- const { appearance, advanced, background, quicklinks } = window.language.modals.main.settings.sections;
- const languageSettings = window.language.modals.main.settings.sections.language;
const theme = (
<>
-
{language.sections.theme.title}
-
{language.sections.theme.description}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.theme.title')}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.theme.description')}
this.changeTheme('auto')}>
-
{appearance.theme.auto}
+
{this.getMessage(this.languagecode, 'modals.main.settings.sections.appearance.theme.auto')}
this.changeTheme('light')}>
- {appearance.theme.light}
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.appearance.theme.light')}
this.changeTheme('dark')}>
- {appearance.theme.dark}
+ {this.getMessage(this.languagecode, 'modals.main.settings.sections.appearance.theme.dark')}
-
{language.tip}
-
{language.sections.theme.tip}
+
{this.getMessage(this.languagecode, 'modals.welcome.tip')}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.theme.tip')}
>
);
const settings = (
<>
-
{language.sections.settings.title}
-
{language.sections.settings.description}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.settings.title')}
+
{this.getMessage(this.languagecode, 'modals.welcome.sections.settings.description')}
this.importSettings(e)}/>
- {language.tip}
- {language.sections.settings.tip}
+ {this.getMessage(this.languagecode, 'modals.welcome.tip')}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.settings.tip')}
>
);
const privacy = (
<>
- {language.sections.privacy.title}
- {language.sections.privacy.description}
-
- {language.sections.privacy.offline_mode_description}
-
-
- {language.sections.privacy.ddg_proxy_description}
- {language.sections.privacy.links.title}
- {language.sections.privacy.links.privacy_policy}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.privacy.title')}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.privacy.description')}
+
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.privacy.offline_mode_description')}
+
+
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.privacy.ddg_proxy_description')}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.privacy.links.title')}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.privacy.links.privacy_policy')}
- {language.sections.privacy.links.source_code}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.privacy.links.source_code')}
>
);
const final = (
<>
- {language.sections.final.title}
- {language.sections.final.description}
- {language.sections.final.changes}
- {language.sections.final.changes_description}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.final.title')}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.final.description')}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.final.changes')}
+ {this.getMessage(this.languagecode, 'modals.welcome.sections.final.changes_description')}
-
this.props.switchTab(1)}>{languageSettings.title}: {languages.find((i) => i.value === localStorage.getItem('language')).name}
-
this.props.switchTab(3)}>{appearance.theme.title}: {this.getSetting('theme')}
- {(this.state.importedSettings.length !== 0) ?
this.props.switchTab(2)}>{language.sections.final.imported} {this.state.importedSettings.length} {language.sections.final.settings}
: null}
+
this.props.switchTab(1)}>{this.getMessage(this.languagecode, 'modals.main.settings.sections.language.title')}: {languages.find((i) => i.value === localStorage.getItem('language')).name}
+
this.props.switchTab(3)}>{this.getMessage(this.languagecode, 'modals.main.settings.sections.appearance.theme.title')}: {this.getSetting('theme')}
+ {(this.state.importedSettings.length !== 0) ?
this.props.switchTab(2)}>{language.sections.final.imported} {this.state.importedSettings.length} {this.getMessage(this.languagecode, 'modals.welcome.sections.final.settings')}
: null}
>
);
diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx
index 34f054ff..8c75b313 100644
--- a/src/components/widgets/background/Background.jsx
+++ b/src/components/widgets/background/Background.jsx
@@ -1,4 +1,5 @@
// todo: rewrite this mess
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import PhotoInformation from './PhotoInformation';
@@ -23,7 +24,6 @@ export default class Background extends PureComponent {
photoURL: ''
}
};
- this.language = window.language.widgets.background;
}
setBackground() {
@@ -134,12 +134,15 @@ export default class Background extends PureComponent {
let credit = data.photographer;
let photoURL, photographerURL;
+ const language = variables.language;
+ const languagecode = variables.languagecode;
+
if (backgroundAPI === 'unsplash') {
- credit = data.photographer + ` ${this.language.unsplash}`;
+ credit = data.photographer + ` ${language.getMessage(languagecode, 'background.unsplash')}`;
photoURL = data.photo_page;
photographerURL = data.photographer_page;
} else if (backgroundAPI === 'pexels') {
- credit = data.photographer + ` ${this.language.pexels}`;
+ credit = data.photographer + ` ${language.getMessage(languagecode, 'background.pexels')}`;
photoURL = data.photo_page;
photographerURL = data.photographer_page;
}
diff --git a/src/components/widgets/background/Favourite.jsx b/src/components/widgets/background/Favourite.jsx
index 79d0afee..41340bb1 100644
--- a/src/components/widgets/background/Favourite.jsx
+++ b/src/components/widgets/background/Favourite.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import { Star, StarBorder } from '@material-ui/icons';
import Hotkeys from 'react-hot-keys';
@@ -57,7 +58,7 @@ export default class Favourite extends PureComponent {
}
return (
-
+
{this.state.favourited}
{window.keybinds.favouriteBackground && window.keybinds.favouriteBackground !== '' ? this.favourite()} /> : null}
diff --git a/src/components/widgets/background/Maximise.jsx b/src/components/widgets/background/Maximise.jsx
index 448f0c4f..cfa10150 100644
--- a/src/components/widgets/background/Maximise.jsx
+++ b/src/components/widgets/background/Maximise.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import { Fullscreen } from '@material-ui/icons';
import Hotkeys from 'react-hot-keys';
@@ -56,7 +57,7 @@ export default class Maximise extends PureComponent {
render() {
return (
-
+
{window.keybinds.maximiseBackground && window.keybinds.maximiseBackground !== '' ? : null}
diff --git a/src/components/widgets/background/PhotoInformation.jsx b/src/components/widgets/background/PhotoInformation.jsx
index dbc8a12c..bf03b2ca 100644
--- a/src/components/widgets/background/PhotoInformation.jsx
+++ b/src/components/widgets/background/PhotoInformation.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { useState, Fragment } from 'react';
import { Info, LocationOn, PhotoCamera, Crop as Resolution, Person as Photographer, GetApp as Download } from '@material-ui/icons';
import Hotkeys from 'react-hot-keys';
@@ -26,26 +27,26 @@ export default function PhotoInformation({ info, url, api }) {
const [width, setWidth] = useState(0);
const [height, setHeight] = useState(0);
- const language = window.language.widgets.background;
-
if (info.hidden === true || !info.credit) {
return null;
}
// remove unsplash and pexels text
- const photographer = info.credit.split(` ${language.unsplash}`)[0].split(` ${language.pexels}`);
+ const unsplash = variables.language.getMessage(variables.languagecode, 'widgets.background.unsplash');
+ const pexels = variables.language.getMessage(variables.languagecode, 'widgets.background.pexels');
+ const photographer = info.credit.split(` ${unsplash}`)[0].split(` ${pexels}`);
- let credit = info.credit;
- let photo = language.credit;
+ let credit;
+ let photo;
// unsplash and pexels credit
if (info.photographerURL && info.photographerURL !== '' && !info.offline && api) {
if (api === 'unsplash') {
- photo = {language.credit};
- credit = <>{photographer} {language.unsplash}>;
+ photo = {variables.language.getMessage(variables.languagecode, 'widgets.background.credit')};
+ credit = <>{photographer} {unsplash}>;
} else {
- photo = {language.credit};
- credit = <>{photographer} {language.pexels}>;
+ photo = {variables.language.getMessage(variables.languagecode, 'widgets.background.credit')};
+ credit = <>{photographer} {pexels}>;
}
}
@@ -126,7 +127,7 @@ export default function PhotoInformation({ info, url, api }) {
-
{language.information}
+
{variables.language.getMessage(variables.languagecode, 'widgets.background.information')}
{photoMap()}
{/* fix console error by using fragment and key */}
@@ -141,11 +142,11 @@ export default function PhotoInformation({ info, url, api }) {
{width}x{height}
-
{photographer}
+
{info.credit}
{downloadEnabled ?
<>
-
downloadImage(info)}>{language.download}
+
downloadImage(info)}>{variables.language.getMessage(variables.languagecode, 'widgets.background.download')}
>
: null}
diff --git a/src/components/widgets/greeting/Greeting.jsx b/src/components/widgets/greeting/Greeting.jsx
index d326066e..4b1955fd 100644
--- a/src/components/widgets/greeting/Greeting.jsx
+++ b/src/components/widgets/greeting/Greeting.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent, createRef } from 'react';
import { nth, convertTimezone } from 'modules/helpers/date';
@@ -12,7 +13,6 @@ export default class Greeting extends PureComponent {
greeting: ''
};
this.timer = undefined;
- this.language = window.language.widgets.greeting;
this.greeting = createRef();
}
@@ -27,13 +27,13 @@ export default class Greeting extends PureComponent {
// If it's December 25th, set the greeting string to "Merry Christmas"
if (month === 11 && date === 25) {
- message = this.language.christmas;
+ message = variables.language.getMessage(variables.languagecode, 'widgets.greeting.christmas');
// If the date is January 1st, set the greeting string to "Happy new year"
} else if (month === 0 && date === 1) {
- message = this.language.newyear;
+ message = variables.language.getMessage(variables.languagecode, 'widgets.greeting.newyear');
// If it's October 31st, set the greeting string to "Happy Halloween"
} else if (month === 9 && date === 31) {
- message = this.language.halloween;
+ message = variables.language.getMessage(variables.languagecode, 'widgets.greeting.halloween');
}
return message;
@@ -56,13 +56,13 @@ export default class Greeting extends PureComponent {
const hour = now.getHours();
// Set the default greeting string to "Good evening"
- let message = this.language.evening;
+ let message = variables.language.getMessage(variables.languagecode, 'widgets.greeting.evening');
// If it's before 12am, set the greeting string to "Good morning"
if (hour < 12) {
- message = this.language.morning;
+ message = variables.language.getMessage(variables.languagecode, 'widgets.greeting.morning');
// If it's before 6pm, set the greeting string to "Good afternoon"
} else if (hour < 18) {
- message = this.language.afternoon;
+ message = variables.language.getMessage(variables.languagecode, 'widgets.greeting.afternoon');
}
// Events and custom
@@ -95,10 +95,10 @@ export default class Greeting extends PureComponent {
if (birth.getDate() === now.getDate() && birth.getMonth() === now.getMonth()) {
if (localStorage.getItem('birthdayage') === 'true') {
- const text = this.language.birthday.split(' ');
+ const text = variables.language.getMessage(variables.languagecode, 'widgets.greeting.birthday').split(' ');
message = `${text[0]} ${nth(this.calculateAge(birth))} ${text[1]}`;
} else {
- message = this.language.birthday;
+ message = variables.language.getMessage(variables.languagecode, 'widgets.greeting.birthday');
}
}
}
diff --git a/src/components/widgets/navbar/Navbar.jsx b/src/components/widgets/navbar/Navbar.jsx
index ea12a0c1..84a83c2c 100644
--- a/src/components/widgets/navbar/Navbar.jsx
+++ b/src/components/widgets/navbar/Navbar.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent, createRef } from 'react';
import { RefreshRounded, SettingsRounded, AssignmentRounded as NotesRounded, SmsFailed as Report } from '@material-ui/icons';
@@ -67,18 +68,18 @@ export default class Navbar extends PureComponent {
: null}
{(window.constants.BETA_VERSION === true) ?
-
+
this.props.openModal('feedbackModal')}/>
: null}
{(this.refreshValue !== 'false') ?
-
+
this.refresh()}/>
: null}
-
+
this.props.openModal('mainModal')}/>
diff --git a/src/components/widgets/navbar/Notes.jsx b/src/components/widgets/navbar/Notes.jsx
index 1d0146f2..68e0f2de 100644
--- a/src/components/widgets/navbar/Notes.jsx
+++ b/src/components/widgets/navbar/Notes.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent } from 'react';
import { FileCopyRounded, AssignmentRounded as NotesRounded, PushPin }from '@material-ui/icons';
import TextareaAutosize from '@material-ui/core/TextareaAutosize';
@@ -12,7 +13,6 @@ export default class Notes extends PureComponent {
visibility: (localStorage.getItem('notesPinned') === 'true') ? 'visible' : 'hidden',
marginLeft: (localStorage.getItem('refresh') === 'false') ? '-200px' : '-150px'
};
- this.language = window.language.widgets.navbar.notes;
}
setNotes = (e) => {
@@ -41,7 +41,7 @@ export default class Notes extends PureComponent {
copy() {
window.stats.postEvent('feature', 'Notes copied');
navigator.clipboard.writeText(this.state.notes);
- toast(window.language.toasts.notes);
+ toast(variables.language.getMessage(variables.languagecode, 'toasts.notes'));
}
render() {
@@ -49,9 +49,9 @@ export default class Notes extends PureComponent {
-
{this.language.title}
+ {variables.language.getMessage(variables.languagecode, 'widgets.navbar.notes.title')}
-
+
{window.keybinds.pinNotes && window.keybinds.pinNotes !== '' ? this.pin()}/> : null}
diff --git a/src/components/widgets/quicklinks/QuickLinks.jsx b/src/components/widgets/quicklinks/QuickLinks.jsx
index 8332b565..0cf4d73f 100644
--- a/src/components/widgets/quicklinks/QuickLinks.jsx
+++ b/src/components/widgets/quicklinks/QuickLinks.jsx
@@ -19,7 +19,6 @@ export default class QuickLinks extends PureComponent {
nameError: '',
urlError: ''
};
- this.language = window.language.widgets.quicklinks;
this.quicklinksContainer = createRef();
}
diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx
index 8da32a54..7ec91c86 100644
--- a/src/components/widgets/quote/Quote.jsx
+++ b/src/components/widgets/quote/Quote.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent, createRef } from 'react';
import { FilterNone as FileCopy, Twitter, Star, StarBorder } from '@material-ui/icons';
import { toast } from 'react-toastify';
@@ -27,7 +28,6 @@ export default class Quote extends PureComponent {
quoteLanguage: '',
type: localStorage.getItem('quoteType') || 'api'
};
- this.language = window.language.widgets.quote;
this.quote = createRef();
this.quotediv = createRef();
this.quoteauthor = createRef();
@@ -55,7 +55,7 @@ export default class Quote extends PureComponent {
}
getAuthorLink(author) {
- let authorlink = `https://${window.languagecode.split('_')[0]}.wikipedia.org/wiki/${author.split(' ').join('_')}`;
+ let authorlink = `https://${variables.languagecode.split('_')[0]}.wikipedia.org/wiki/${author.split(' ').join('_')}`;
if (localStorage.getItem('authorLink') === 'false' || author === 'Unknown') {
authorlink = null;
}
@@ -163,7 +163,7 @@ export default class Quote extends PureComponent {
copyQuote() {
window.stats.postEvent('feature', 'Quote copied');
navigator.clipboard.writeText(`${this.state.quote} - ${this.state.author}`);
- toast(window.language.toasts.quote);
+ toast(variables.language.getMessage(variables.languagecode, 'toasts.quote'));
}
tweetQuote() {
diff --git a/src/components/widgets/search/Search.jsx b/src/components/widgets/search/Search.jsx
index a6124c84..20a4712e 100644
--- a/src/components/widgets/search/Search.jsx
+++ b/src/components/widgets/search/Search.jsx
@@ -1,3 +1,4 @@
+import variables from 'modules/variables';
import { PureComponent, Fragment } from 'react';
import { Search as SearchIcon, Mic } from '@material-ui/icons';
import Hotkeys from 'react-hot-keys';
@@ -24,7 +25,6 @@ export default class Search extends PureComponent {
suggestions: [],
searchDropdown: 'hidden'
};
- this.language = window.language.widgets.search;
}
startSpeechRecognition = () => {
@@ -169,7 +169,7 @@ export default class Search extends PureComponent {
}
render() {
- const customText = window.language.modals.main.settings.sections.search.custom.split(' ')[0];
+ const customText = variables.language.getMessage(variables.languagecode, 'modals.main.settings.sections.search.custom').split(' ')[0];
return (
: null}
{this.state.microphone}