Skip to content

Latest commit

 

History

History
75 lines (58 loc) · 2.02 KB

README.md

File metadata and controls

75 lines (58 loc) · 2.02 KB

ytrans.js Build Status NPM

Usage:

  • If you don't already have one, get an API key here
    var ytrans = require('ytrans.js');
    var yt = new ytrans();
    yt.set_key(API_KEY);

    yt.translate('Hello there!', function(err, result) {
        ...;
    });
    yt.set_default_lang("sk", function(err, success) {
        if (err || ! success)
            console.log("Failed to set the default language: look at results ", arguments);
        else
            console.log("Successfully set the default language!");
    });
    yt.translate({
        text: ['кофе', 'Я знаю, французской и правда'], lang: 'de'
    }, function(err, translation) {
        ...;
    });
    var ytk = new ytrans({api_key_path: API_KEY_PATH});
    ytk.get_allowed_translations("uk", function(err, secondaries) {
        ...;
    });
    var ytk1 = new ytrans(API_KEY_PATH);
    ytk1.translate_file({
        path: TARGET_FILE, lang: 'cs-ru'
    }, function(err, content) {
        ...;
    });

    ytk1.is_allowed_transition("ru", "ch", function(err, validity) {
        ...;
    });
    var catfish = new ytrans(API_KEY_PATH);
    catfish.translate({
        text: ["Je sais espagnol pour de vrai, je suis couché LOL"], lang: "es"
    }, function(err, res) {
        ...;
    });