diff --git a/electron-builder.yml b/electron-builder.yml index 0ae60919..819fcf5f 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -69,5 +69,4 @@ linux: - AppImage icon: build/icons category: Utility - desktop: - StartupWMClass: fluent-reader + desktop: {} \ No newline at end of file diff --git a/src/components/article.tsx b/src/components/article.tsx index 18a640ab..c81d295e 100644 --- a/src/components/article.tsx +++ b/src/components/article.tsx @@ -44,6 +44,7 @@ type ArticleProps = { type ArticleState = { fontFamily: string fontSize: number + translated: boolean loadWebpage: boolean loadFull: boolean fullContent: string @@ -60,6 +61,7 @@ class Article extends React.Component { this.state = { fontFamily: window.settings.getFont(), fontSize: window.settings.getFontSize(), + translated: false, loadWebpage: props.source.openTarget === SourceOpenTarget.Webpage, loadFull: props.source.openTarget === SourceOpenTarget.FullContent, fullContent: "", @@ -288,8 +290,7 @@ class Article extends React.Component { loadWebpage: this.props.source.openTarget === SourceOpenTarget.Webpage, loadFull: - this.props.source.openTarget === - SourceOpenTarget.FullContent, + this.props.source.openTarget === SourceOpenTarget.FullContent, }) if (this.props.source.openTarget === SourceOpenTarget.FullContent) this.loadFull() @@ -304,6 +305,17 @@ class Article extends React.Component { if (refocus) refocus.focus() } + toggleTranslation = () => { + if (this.state.translated) { + this.setState({ translated: false }) + } else if ( + this.props.item.link.startsWith("https://") || + this.props.item.link.startsWith("http://") + ) { + this.setState({ translated: true }) + } + } + toggleWebpage = () => { if (this.state.loadWebpage) { this.setState({ loadWebpage: false }) @@ -439,6 +451,18 @@ class Article extends React.Component { this.props.toggleStarred(this.props.item) } /> + {this.state.loadWebpage && ( + + )} { } src={ this.state.loadWebpage - ? this.props.item.link + ? this.state.translated + ? `https://translate.google.com/translate?sl=auto&tl=${this.props.locale.split("-")[0]}&u=${encodeURIComponent(this.props.item.link)}` + : this.props.item.link : this.articleView() } allowpopups={"true" as unknown as boolean} diff --git a/src/scripts/i18n/en-US.json b/src/scripts/i18n/en-US.json index fad7eacd..faf09f81 100644 --- a/src/scripts/i18n/en-US.json +++ b/src/scripts/i18n/en-US.json @@ -64,6 +64,8 @@ "star": "Star", "unstar": "Remove star", "fontSize": "Font size", + "translate": "Translate article", + "untranslate": "Show original", "loadWebpage": "Load webpage", "loadFull": "Load full content", "notify": "Notify if fetched in background", diff --git a/src/scripts/i18n/pt-BR.json b/src/scripts/i18n/pt-BR.json index d713081c..6d0fc6d8 100644 --- a/src/scripts/i18n/pt-BR.json +++ b/src/scripts/i18n/pt-BR.json @@ -63,6 +63,8 @@ "star": "Marcar como favorito", "unstar": "Remover marcação", "fontSize": "Tamanho da fonte", + "translate": "Traduzir artigo", + "untranslate": "Mostrar original", "loadWebpage": "Carregar página web", "loadFull": "Carregar todo o conteúdo", "notify": "Notificar se atualizado em segundo plano", diff --git a/src/scripts/i18n/pt-PT.json b/src/scripts/i18n/pt-PT.json index 56354b26..5a8f9105 100644 --- a/src/scripts/i18n/pt-PT.json +++ b/src/scripts/i18n/pt-PT.json @@ -64,6 +64,8 @@ "star": "Marcar como favorito", "unstar": "Remover marcação", "fontSize": "Tamanho da fonte", + "translate": "Traduzir artigo", + "untranslate": "Mostrar original", "loadWebpage": "Carregar página web", "loadFull": "Carregar todo o conteúdo", "notify": "Notificar se atualizado em segundo plano",