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

Commit

Permalink
Add option to show/hide transliteration (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 authored May 22, 2020
1 parent b0fb1d1 commit 9e82cd2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions public/libs/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,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

0 comments on commit 9e82cd2

Please sign in to comment.