Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Add option to show/hide transliteration #162

Merged
merged 2 commits into from
May 22, 2020
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
1 change: 1 addition & 0 deletions public/libs/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"attachToMenubar": "Attach to menubar",
"attachToTaskbar": "Attach to taskbar",
"translateWhenPressingEnter": "Translate when pressing Enter",
"showTransliteration": "Show transliteration",
"realtime": "Real-time translation",
"realtimeDesc": "This feature only works with text no longer than 280 characters.",
"rateMacAppStore": "Rate Translatium on Mac App Store",
Expand Down
1 change: 1 addition & 0 deletions public/libs/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const defaultPreferences = {
realtime: true,
recentLanguages: ['en', 'zh'],
registered: getDefaultRegistered(),
showTransliteration: true,
themeSource: 'system',
translateClipboardOnShortcut: false,
translateWhenPressingEnter: true,
Expand Down
7 changes: 5 additions & 2 deletions src/components/pages/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class Home extends React.Component {
onUpdateInputText,
onUpdateOutputLang,
output,
showTransliteration,
textToSpeechPlaying,
} = this.props;

Expand Down Expand Up @@ -340,7 +341,7 @@ class Home extends React.Component {
{ [classes.resultContainerHidden]: fullscreenInputBox },
)}
>
{output.inputRoman && (
{showTransliteration && output.inputRoman && (
<Typography
variant="body2"
color="textSecondary"
Expand All @@ -359,7 +360,7 @@ class Home extends React.Component {
{output.outputText}
</Typography>

{output.outputRoman && (
{showTransliteration && output.outputRoman && (
<Typography variant="body2" color="textSecondary" className={classNames('text-selectable', classes.pos)}>
{output.outputRoman}
</Typography>
Expand Down Expand Up @@ -658,6 +659,7 @@ Home.propTypes = {
output: PropTypes.object,
outputLang: PropTypes.string.isRequired,
registered: PropTypes.bool.isRequired,
showTransliteration: PropTypes.bool.isRequired,
textToSpeechPlaying: PropTypes.bool.isRequired,
translateWhenPressingEnter: PropTypes.bool.isRequired,
};
Expand All @@ -669,6 +671,7 @@ const mapStateToProps = (state) => ({
output: state.pages.home.output,
outputLang: state.preferences.outputLang,
registered: state.preferences.registered,
showTransliteration: state.preferences.showTransliteration,
textToSpeechPlaying: state.pages.home.textToSpeech.textToSpeechPlaying,
translateWhenPressingEnter: state.preferences.translateWhenPressingEnter,
});
Expand Down
15 changes: 15 additions & 0 deletions src/components/pages/preferences/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const Preferences = (props) => {
openAtLogin,
openOnMenubarShortcut,
realtime,
showTransliteration,
themeSource,
translateClipboardOnShortcut,
translateWhenPressingEnter,
Expand Down Expand Up @@ -169,6 +170,18 @@ const Preferences = (props) => {
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem>
<ListItemText primary={getLocale('showTransliteration')} />
<ListItemSecondaryAction>
<Switch
edge="end"
checked={showTransliteration}
onChange={() => onToggleSetting('showTransliteration')}
color="primary"
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem>
<ListItemText primary={getLocale('translateWhenPressingEnter')} />
<ListItemSecondaryAction>
Expand Down Expand Up @@ -396,6 +409,7 @@ Preferences.propTypes = {
openAtLogin: PropTypes.oneOf(['yes', 'yes-hidden', 'no']).isRequired,
openOnMenubarShortcut: PropTypes.string,
realtime: PropTypes.bool.isRequired,
showTransliteration: PropTypes.bool.isRequired,
themeSource: PropTypes.string.isRequired,
translateClipboardOnShortcut: PropTypes.bool.isRequired,
translateWhenPressingEnter: PropTypes.bool.isRequired,
Expand All @@ -408,6 +422,7 @@ const mapStateToProps = (state) => ({
openAtLogin: state.systemPreferences.openAtLogin,
openOnMenubarShortcut: state.preferences.openOnMenubarShortcut,
realtime: state.preferences.realtime,
showTransliteration: state.preferences.showTransliteration,
themeSource: state.preferences.themeSource,
translateClipboardOnShortcut: state.preferences.translateClipboardOnShortcut,
translateWhenPressingEnter: state.preferences.translateWhenPressingEnter,
Expand Down