Skip to content

Commit 4261fa2

Browse files
committed
fix: pirate translator.
1 parent 4a1d4eb commit 4261fa2

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

src/pages/apps/PirateTranslatorPage.js

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,66 @@ import useSeo from '../../hooks/useSeo';
77
const pirateDictionary = {
88
"hello": "ahoy",
99
"hi": "ahoy",
10+
"hey": "ahoy",
1011
"my": "me",
1112
"friend": "matey",
13+
"friends": "hearties",
1214
"is": "be",
1315
"are": "be",
16+
"am": "be",
1417
"you": "ye",
1518
"your": "yer",
19+
"yours": "yers",
1620
"where": "whar",
1721
"to": "t'",
1822
"the": "th'",
1923
"of": "o'",
24+
"for": "fer",
2025
"stop": "avast",
2126
"yes": "aye",
2227
"no": "nay",
2328
"girl": "lass",
29+
"girls": "lassies",
2430
"boy": "lad",
31+
"boys": "laddies",
32+
"guy": "lubber",
33+
"man": "scallywag",
34+
"woman": "wench",
2535
"money": "booty",
36+
"cash": "doubloons",
2637
"quickly": "smartly",
38+
"fast": "smartly",
2739
"captain": "cap'n",
2840
"beer": "grog",
41+
"alcohol": "rum",
2942
"water": "brine",
43+
"wine": "grog",
44+
"drink": "swig",
3045
"happy": "jolly",
3146
"good": "grand",
3247
"bad": "scurvy",
3348
"very": "mighty",
3449
"wow": "blimey",
3550
"there": "thar",
3651
"mad": "addled",
52+
"crazy": "mad as a hatter",
3753
"boss": "admiral",
3854
"food": "grub",
3955
"hotel": "inn",
4056
"house": "shack",
57+
"home": "port",
4158
"kill": "keelhaul",
4259
"died": "walked the plank",
60+
"dead": "feeding the fish",
4361
"old": "barnacle-covered",
4462
"bathroom": "head",
4563
"restroom": "head",
4664
"toilet": "head",
4765
"wife": "ball and chain",
66+
"husband": "old man",
4867
"song": "shanty",
4968
"music": "shanty",
50-
"cheat": "swindle",
69+
"cheat": "hornswaggle",
5170
"rob": "pillage",
5271
"steal": "plunder",
5372
"take": "seize",
@@ -56,8 +75,36 @@ const pirateDictionary = {
5675
"knife": "dagger",
5776
"ship": "vessel",
5877
"boat": "dinghy",
78+
"sea": "big blue wet thing",
79+
"ocean": "seven seas",
80+
"treasure": "treasure",
81+
"chest": "coffer",
82+
"talk": "parley",
83+
"speak": "parley",
84+
"look": "spy",
85+
"saw": "spied",
86+
"find": "come across",
87+
"run": "scamper",
88+
"leave": "weigh anchor",
89+
"after": "aft",
90+
"forward": "fore",
5991
};
6092

93+
const piratePhrases = [
94+
" Arrr!",
95+
" Shiver me timbers!",
96+
" Walk the plank!",
97+
" Yo ho ho!",
98+
" Avast ye!",
99+
" Dead men tell no tales.",
100+
" By Blackbeard's ghost!",
101+
" Blow me down!",
102+
" Savvy?",
103+
" ...and a bottle of rum!",
104+
" Weigh anchor!",
105+
" Batten down the hatches!",
106+
];
107+
61108
const PirateTranslatorPage = () => {
62109
useSeo({
63110
title: 'Pirate Speak Translator | Fezcodex',
@@ -77,16 +124,22 @@ const PirateTranslatorPage = () => {
77124

78125
const translate = () => {
79126
let text = inputText.toLowerCase();
127+
// Dictionary replacements
80128
Object.keys(pirateDictionary).forEach(key => {
81-
const regex = new RegExp(`\b${key}\b`, 'g');
129+
const regex = new RegExp(`\\b${key}\\b`, 'g');
82130
text = text.replace(regex, pirateDictionary[key]);
83131
});
132+
133+
// Grammar tweaks: replacing 'ing' at the end of words with "in'"
134+
text = text.replace(/ing\b/g, "in'");
135+
84136
// Capitalize first letter of sentences
85137
text = text.replace(/(^\w|\.\s\w)/g, c => c.toUpperCase());
86138

87139
// Add some pirate flair randomly
88-
if (text.length > 0 && Math.random() > 0.5) {
89-
text += " Arrr!";
140+
if (text.length > 0) {
141+
const randomPhrase = piratePhrases[Math.floor(Math.random() * piratePhrases.length)];
142+
text += randomPhrase;
90143
}
91144

92145
setTranslatedText(text);

0 commit comments

Comments
 (0)