diff --git a/src/components/article.tsx b/src/components/article.tsx index 18a640ab..797b636b 100644 --- a/src/components/article.tsx +++ b/src/components/article.tsx @@ -44,6 +44,7 @@ type ArticleProps = { type ArticleState = { fontFamily: string fontSize: number + translate: 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(), + translate: 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.translate) { + this.setState({ translate: false }) + } else if ( + this.props.item.link.startsWith("https://") || + this.props.item.link.startsWith("http://") + ) { + this.setState({ translate: 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.translate + ? `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..626d1af3 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", + "showOriginal": "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..079067eb 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", + "showOriginal": "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..aac0871a 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", + "showOriginal": "Mostrar original", "loadWebpage": "Carregar página web", "loadFull": "Carregar todo o conteúdo", "notify": "Notificar se atualizado em segundo plano",