Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap all text in i18next functions #1087

Merged
merged 14 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/app/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Icon } from 'semantic-ui-react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { NavLink, withRouter } from 'react-router-dom';

import classnames from 'classnames';
import _ from 'lodash';
import Sound from 'react-hifi';
import { withTranslation } from 'react-i18next';
import { PluginConfig } from '@nuclear/core';

import * as SearchActions from './actions/search';
import * as PlayerActions from './actions/player';
import * as PlaylistsActions from './actions/playlists';
Expand Down Expand Up @@ -157,7 +157,7 @@ class App extends React.PureComponent {
src={this.props.settings.compactMenuBar ? logoIcon : logoImg}
/>
<div className={styles.version_string}>
{this.props.settings.compactMenuBar ? '0.6.17' : 'Version 0.6.17'}
{this.props.settings.compactMenuBar ? '0.6.17' : this.props.t('version') + ' 0.6.17'}
</div>
</div>
<div className={styles.sidebar_menus}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const DownloadsHeader = ({
}) => (
<Segment className={styles.downloads_header}>
<span className={styles.label}>
Saving in:
{/* change */}
{t('saving-in')}
<span className={styles.directory}>
{ _.isEmpty(directory) ? remote.app.getPath('downloads') : directory}
</span>
Expand Down
55 changes: 29 additions & 26 deletions packages/app/app/components/EqualizerPresetList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,38 @@ import React from 'react';
import PropTypes from 'prop-types';
import { List, Icon } from 'semantic-ui-react';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';

import styles from './styles.scss';

const EqualizerPresetList = ({ presets, onClickItem, selected }) => (
<div className={styles.preset_list_container}>
<h3>Presets</h3>
<List divided verticalAlign='middle' className={styles.equalizer_list}>
{presets.map((preset, index) => (
<List.Item
key={index}
onClick={() => preset !== selected && onClickItem(preset.id)}
className={
classNames(
styles.equalizer_item,
{
[styles.equalizer_click_item]: preset.id !== selected
})
}
>
<List.Content floated='right'>
{preset.id === selected && <Icon name='check' />}
</List.Content>
<List.Content>{preset.label}</List.Content>
</List.Item>
))}
</List>
</div>
);

const EqualizerPresetList = ({ presets, onClickItem, selected }) => {
const { t } = useTranslation('equalizer');
return (
<div className={styles.preset_list_container}>
<h3>{t('presets')}</h3>
<List divided verticalAlign='middle' className={styles.equalizer_list}>
{presets.map((preset, index) => (
<List.Item
key={index}
onClick={() => preset !== selected && onClickItem(preset.id)}
className={
classNames(
styles.equalizer_item,
{
[styles.equalizer_click_item]: preset.id !== selected
})
}
>
<List.Content floated='right'>
{preset.id === selected && <Icon name='check' />}
</List.Content>
<List.Content>{t(preset.label)}</List.Content>
</List.Item>
))}
</List>
</div>
);
};
EqualizerPresetList.propTypes = {
presets: PropTypes.array.isRequired,
onClickItem: PropTypes.func,
Expand Down
2 changes: 1 addition & 1 deletion packages/app/app/components/HelpModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const HelpModal: React.FC<HelpModalProps> = ({
<Modal.Content>
<div className={styles.contributors}>
<Header className={styles.contributors_header}>
Our top 10 Contributors
{t('contributors')}
</Header>
<Contributors
{...githubContrib}
Expand Down
14 changes: 7 additions & 7 deletions packages/app/app/components/SearchResults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,39 +111,39 @@ class SearchResults extends React.Component {

const panes = [
{
menuItem: 'All',
menuItem: this.props.t('all'),
render: () => this.renderAllResultsPane()
},
artistsHasResults && {
menuItem: 'Artists',
menuItem: this.props.t('artist_plural'),
render: () =>
this.renderPane(
this.props.artistSearchResults,
this.artistInfoSearch.bind(this)
)
},
albumsHasResults && {
menuItem: 'Albums',
menuItem: this.props.t('album_plural'),
render: () =>
this.renderPane(
this.props.albumSearchResults,
this.albumInfoSearch.bind(this)
)
},
tracksHasResults && {
menuItem: 'Tracks',
menuItem: this.props.t('track_plural'),
render: () => this.renderTrackListPane(this.props.trackSearchResults.info)
},
playlistsHasResults && {
menuItem: 'Playlist',
menuItem: this.props.t('playlist'),
render: () => this.renderPlaylistPane()
},
liveStreamsHasResults && {
menuItem: 'LiveStream',
menuItem: this.props.t('live-stream'),
render: () => this.renderTrackListPane(this.props.liveStreamSearchResults.info)
},
podcastsHasResults && {
menuItem: 'Podcast',
menuItem: this.props.t('podcast'),
render: () =>
this.renderPane(
this.props.podcastSearchResults,
Expand Down
4 changes: 2 additions & 2 deletions packages/app/app/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const Settings: React.FC<SettingsProps> = ({

const renderSliderOption = (option) => (
<div className={styles.slider_container}>
<label>Less</label>
<label>{t('less')}</label>
<Range
value={getOptionValue(option) || option.default}
min={option.min}
Expand All @@ -150,7 +150,7 @@ const Settings: React.FC<SettingsProps> = ({
width='auto'
onChange={(e) => handleSliderChange(e, option)}
thumbSize={21} />
<label>More</label>
<label>{t('more')}</label>
</div>
);

Expand Down
4 changes: 3 additions & 1 deletion packages/app/app/containers/EqualizerViewContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { bindActionCreators } from 'redux';
import * as EqualizerActions from '../../actions/equalizer';
import Equalizer from '../../components/Equalizer';
import EqualizerPresetList from '../../components/EqualizerPresetList';
import { useTranslation } from 'react-i18next';

import styles from './styles.scss';

Expand All @@ -22,9 +23,10 @@ const EqualizerViewContainer = () => {
const dispatch = useDispatch();
const actions = useMemo(() => bindActionCreators(EqualizerActions, dispatch), [dispatch]);
const presets = usePresets();
const { t } = useTranslation('app');
return (
<div className={styles.equalizer_view}>
<h1>Equalizer</h1>
<h1>{t('equalizer')}</h1>
<div className={styles.equalizer_components}>
<Equalizer
values={preset.values}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { buildStoreState } from '../../../test/storeBuilders';
import { mountedComponentFactory } from '../../../test/testUtils';
import { mountedComponentFactory, setupI18Next } from '../../../test/testUtils';

describe('Settings view container', () => {
beforeAll(() => {
setupI18Next();
});
it('should render settings', () => {
const { component } = mountComponent();
expect(component.asFragment()).toMatchSnapshot();
Expand Down
Loading