Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translating on windows with electron app throwing an error #16

Closed
alvapatrice opened this issue Sep 22, 2017 · 4 comments
Closed

translating on windows with electron app throwing an error #16

alvapatrice opened this issue Sep 22, 2017 · 4 comments

Comments

@alvapatrice
Copy link

Couldn't retrieve a valid JSON response. Perhaps the API has changed, please let us know.

What's the problem with my application?

@statickidz
Copy link
Owner

Hi alvapatrice, I just force build and its passing the tests. Maybe its something with your implementation. Can you give me more details in how you're working with that?

@alvapatrice
Copy link
Author

here are the source code

'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _vuex = require('vuex');

var _nodeGoogleTranslateSkidz = require('node-google-translate-skidz');

var _nodeGoogleTranslateSkidz2 = _interopRequireDefault(_nodeGoogleTranslateSkidz);

var _languages = require('../utils/languages');

var _languages2 = _interopRequireDefault(_languages);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = {
template: '

\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t {{lang.text}} \n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<button id="switch-languages" title="Switch Languages" @click="switchLangs">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t {{lang.text}} \n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<textarea v-model="sourceText" placeholder="Source Text" maxlength="1000" @keyup.enter="translate"></textarea>\n\t\t\t\t\t\t\t\t\t {{ sourceText.length }} / 1000 \n\t\t\t\t\t\t\t\t\t<textarea v-model="targetText" placeholder="Target Text">{{targetText}}</textarea>\n\t\t\t\t\t\t\t\t\t<button id="clear-translate-btn" class="fl" @click="clearText">Clear\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t<button id="translate-btn" class="fr royal" @click="translate">Translate',
data: function data() {
return {
sourceText: '',
targetText: '',
languages: _languages2.default,
sourceSelectedLang: 'en',
targetSelectedLang: 'tr',
transLoader: false
};
},

methods: {
	translate: function translate() {
		var _this = this;

		if (this.sourceText) {
			this.transLoader = true;
			try {
				(0, _nodeGoogleTranslateSkidz2.default)({
					text: this.sourceText,
					source: this.sourceSelectedLang,
					target: this.targetSelectedLang
				}, function (result) {
					if (result.translation) {
						_this.targetText = result.translation;
						_this.transLoader = false;
					} else _this.transLoader = false;
				});
			} catch (error) {
				this.transLoader = false;
			}
		}
	},
	switchLangs: function switchLangs() {
		var temp = this.sourceSelectedLang;
		this.sourceSelectedLang = this.targetSelectedLang;
		this.targetSelectedLang = temp;
		temp = this.sourceText;
		this.sourceText = this.targetText;
		this.targetText = temp;
	},
	clearText: function clearText() {
		this.sourceText = this.targetText = '';
	}
},
computed: _extends({}, (0, _vuex.mapGetters)({
	showTranslate: 'showTranslate'
}))

};

I think there is no usage mistake.

@alvapatrice
Copy link
Author

alvapatrice commented Sep 22, 2017

while trying to find where the problem is, I have tried to to make a request on the API url used in your lib/translate.js using Postman.

  1. here is my post request header
    image2

  2. Here is the body part
    image3

  3. And it returns the not found error
    image1

So can you figure out where should be the source of the problem? For me I think as long as with postman its self can't get a valid response, the API url might have a problem.

@statickidz
Copy link
Owner

@alvapatrice you're using old library version, please update to 1.1.1 in your package.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants