move languages out of redux

This commit is contained in:
Jeremy Kauffman 2019-10-03 12:55:21 -04:00
parent 9ef319341c
commit a96ff9eb1a
5 changed files with 14 additions and 13 deletions

View file

@ -1,13 +1,12 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import * as SETTINGS from 'constants/settings'; import * as SETTINGS from 'constants/settings';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting, selectLanguages } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { doToast } from 'lbry-redux'; import { doToast } from 'lbry-redux';
import SettingLanguage from './view'; import SettingLanguage from './view';
const select = state => ({ const select = state => ({
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state), language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
languages: selectLanguages(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -7,7 +7,6 @@ import { SETTINGS } from 'lbry-redux';
type Props = { type Props = {
language: string, language: string,
languages: {},
showToast: ({}) => void, showToast: ({}) => void,
setClientSetting: (string, boolean) => void, setClientSetting: (string, boolean) => void,
}; };
@ -15,7 +14,10 @@ type Props = {
function SettingLanguage(props: Props) { function SettingLanguage(props: Props) {
const [isFetching, setIsFetching] = useState(false); const [isFetching, setIsFetching] = useState(false);
const { language, languages, showToast, setClientSetting } = props; // this should be fetched from lbry.com/transifex
const languages = { en: 'English', pl: 'Polski', id: 'Bahasa Indonesia', de: 'Deutsche' };
const { language, showToast, setClientSetting } = props;
function onLanguageChange(e) { function onLanguageChange(e) {
const { value } = e.target; const { value } = e.target;
@ -33,7 +35,6 @@ function SettingLanguage(props: Props) {
setClientSetting(SETTINGS.LANGUAGE, value); setClientSetting(SETTINGS.LANGUAGE, value);
}) })
.catch(e => { .catch(e => {
console.log(e);
showToast({ showToast({
message: __('Failed to load translations.'), message: __('Failed to load translations.'),
error: true, error: true,

View file

@ -5,7 +5,6 @@ import moment from 'moment';
const reducers = {}; const reducers = {};
const defaultState = { const defaultState = {
isNight: false, isNight: false,
languages: { en: 'English', pl: 'Polski', id: 'Bahasa Indonesia', de: 'Deutsche', tr: `Türkçe` }, // this could/should be loaded directly from Transifex and/or lbry.com
isFetchingLanguage: false, isFetchingLanguage: false,
daemonSettings: {}, daemonSettings: {},
clientSettings: { clientSettings: {

View file

@ -27,11 +27,6 @@ export const makeSelectClientSetting = setting =>
// refactor me // refactor me
export const selectShowMatureContent = makeSelectClientSetting(SETTINGS.SHOW_MATURE); export const selectShowMatureContent = makeSelectClientSetting(SETTINGS.SHOW_MATURE);
export const selectLanguages = createSelector(
selectState,
state => state.languages
);
export const selectTheme = makeSelectClientSetting(SETTINGS.THEME); export const selectTheme = makeSelectClientSetting(SETTINGS.THEME);
export const selectAutomaticDarkModeEnabled = makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED); export const selectAutomaticDarkModeEnabled = makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED);
export const selectIsNight = createSelector( export const selectIsNight = createSelector(

View file

@ -723,5 +723,12 @@
"Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.": "Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.", "Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.": "Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.",
"This will add a Support button along side tipping. Similar to tips, supports help %discovery_link% but the LBC is returned to your wallet if revoked. Both also help secure your %vanity_names_link%.": "This will add a Support button along side tipping. Similar to tips, supports help %discovery_link% but the LBC is returned to your wallet if revoked. Both also help secure your %vanity_names_link%.", "This will add a Support button along side tipping. Similar to tips, supports help %discovery_link% but the LBC is returned to your wallet if revoked. Both also help secure your %vanity_names_link%.": "This will add a Support button along side tipping. Similar to tips, supports help %discovery_link% but the LBC is returned to your wallet if revoked. Both also help secure your %vanity_names_link%.",
"Save Password": "Save Password", "Save Password": "Save Password",
"Automatically unlock your wallet on startup": "Automatically unlock your wallet on startup" "Automatically unlock your wallet on startup": "Automatically unlock your wallet on startup",
"Dark": "Dark",
"light": "light",
"dark": "dark",
"Live help is available most hours in the %channel% channel of our Discord chat room. Or you can always email us at help@lbry.com.": "Live help is available most hours in the %channel% channel of our Discord chat room. Or you can always email us at help@lbry.com.",
"Your LBRY credits are controllable by you and only you, via a wallet file stored locally on your computer.": "Your LBRY credits are controllable by you and only you, via a wallet file stored locally on your computer.",
"However, it is easy to back up manually. To backup your wallet, make a copy of the folder listed below:": "However, it is easy to back up manually. To backup your wallet, make a copy of the folder listed below:",
"Access to these files are equivalent to having access to your credits. Keep any copies you make of your wallet in a secure place. For more details on backing up and best practices %helpLink%.": "Access to these files are equivalent to having access to your credits. Keep any copies you make of your wallet in a secure place. For more details on backing up and best practices %helpLink%."
} }