JSFiddle - React, Tailwind, and code Playground

by Kevin Faulhaber

HTML

<textarea id="english" type="text" placeholder="english" rows="10"></textarea>
<textarea id="pirate" placeholder="pirate" rows="10"></textarea>
<button id="translate">Translate</button>

JavaScript

var Dictionary = {
    hello: "ahoy",
    hi: "yohoho",
    pardon: [1, {
        me: "avast"
    }],
    excuse: [1, {
        me: "arrr"
    }],
    stranger: "scurvy",
    sir: "matey",
    madam: "proud beauty",
    miss: "comely wench",
    officer: "foul blaggart",
    enemy: "scallywag",
    where: [1, {
        is: "whar be"
    }],
    can: [4, {
        you_help_me_find: "know ye"
    }],
    is: [1, {
        that: "be that"
    }],
    how: [4, {
        far_is_it_to: "how many leagues to"
    }],
    the: "th",
    a: "a briny",
    any: "some godforsaken",
    nearby: "broadside",
    my: "me",
    your: "yer",
    old: "barnacle-covered",
    attractive: "comely",
    happy: "grog-filled",
    restroom: "head",
    restaurant: "galley",
    hotel: "fleabag inn",
    mall: "market",
    pub: "Skull & Scuppers",
    bank: "buried trasure",
    would: [1, {
        like: "be needin"
    }],
    I: [
        [1, {
            desire: "I have a fierce fire in me belly"
        }],
        [5, {
            wish_I_knew_how_to: "I be hankerin to"
        }]
    ],
    my: [
        [4, {
            mother_told_me_to: "me dear ol mum, bless her black soul, tol me to"
        }],
        [4, {
            companion_would_like_to: "me mate, ol Rumpot, wants to"
        }]
    ],
    find: "come across",
    take: [2, {
        a_nap: "have a bit of a lie down"
    }],
    make: [2, {
        a_withdrawal: "seize all yer doubloons"
    }],
    have: [2, {
        a_cocktail: "swill a pint or two of grog"
    }],
    kill: [1, {
        him: "blow the man down"
    }],
    frown: "hang the jib",
    take: [2, {
        a_hike: "walk the plank"
    }]

};

function translate(text) {
    var hop = 1;
    var textToReturn = "";
    //checking if the text is already split, if not we split
    if (typeof text === 'string') {
        text = text.split(' ');
    }
    if (text.length > 0) {
        if (typeof Dictionary[text[0]] == 'undefined' || typeof...