shin10kudev / angular-gengo-app

Japanese language learning app built in Angular4 w/angularFirebase2 and Firebase realtime db
2 stars 0 forks source link

Fix translate API call for japanese #24

Closed shin10kudev closed 7 years ago

shin10kudev commented 7 years ago

Perhaps this is a problem with the source text format

https://cloud.google.com/translate/docs/reference/translate

**format** | stringThe format of the source text, in either HTML (default) or plain-text. A value of html indicates HTML and a value of text indicates plain-text.

Take a look into the format parameter

shin10kudev commented 7 years ago

SOLUTION:

http://www.kanjidatabase.com/japanese_developer_tips.php (edited)

key point:

So I changed my code to:

    var source = 'ja';
    var target = 'en';
    var text = encodeURIComponent(snapshot.val().ja);
    promises.push(createTranslationPromise(source, target, text, snapshot, userId));

I noticed this by copy/pasting the Google Translate API url directly into my text editor, and saw the Japanese for 日本 was converted into %E6%97%A5%E6%9C%AC.

shin10kudev commented 7 years ago

Fixed