Skip to content

Commit

Permalink
Merge branch 'v2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
xfslove committed Oct 24, 2019
2 parents 7c8db18 + 0575126 commit 7e39e05
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*Requires [Node.js](https://nodejs.org) 8+ and the Alfred 3 or 4 [Powerpack](https://www.alfredapp.com/powerpack/).*

- install with `npm install -g alfred-google-translate`
- or [download](https://github.com/xfslove/alfred-google-translate/releases/tag/v2.0.6) workflow
- or [download](https://github.com/xfslove/alfred-google-translate/releases/tag/v2.0.8) workflow

## [Changelog](https://github.com/xfslove/alfred-google-translate/releases)

Expand Down Expand Up @@ -71,6 +71,8 @@ if you download the workflow, you may lost the hotkey, so you can manual config

- correct

![](media/detect-lang.png)

![corrected.png](media/corrected.png)

- press <kbd>enter</kbd> to read,press<kbd>cmd</kbd>+<kbd>C</kbd> to copy
Expand Down
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var os = require('os');
var uuidv4 = require('uuid/v4');
var languagePair = new configstore('language-config-pair');
var history = new configstore("translate-history");
var languages = require("./languages");

var g_config = {
voice: process.env.voice || 'remote',
Expand Down Expand Up @@ -43,7 +44,8 @@ if (pair) {
})
.then(function (res) {
var detect = res.from.language.iso;
var from, to;
var from = 'auto';
var to = 'en';
if (pair0 === detect) {
from = pair0;
to = pair1;
Expand Down Expand Up @@ -102,7 +104,14 @@ function doTranslate(opts) {
.then(function (res) {
var items = [];

if (res.from.corrected.corrected || res.from.corrected.didYouMean) {
if ('auto' === opts.from.language || res.from.language.didYouMean) {
// Detected the input language not in configuration
items.push({
title: res.to.text.value,
subtitle: `Detected the input language is ${languages[res.from.language.iso]}, not one of your configuration.`
});

} else if (res.from.corrected.corrected || res.from.corrected.didYouMean) {

var corrected = res.from.corrected.value
.replace(/\[/, "")
Expand Down
Binary file added media/detect-lang.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alfred-google-translate",
"version": "2.0.7",
"version": "2.0.8",
"description": "Alfred 3 workflow to translate with google translate api",
"license": "MIT",
"repository": "xfslove/alfred-google-translate",
Expand Down

0 comments on commit 7e39e05

Please sign in to comment.