Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
NOTE: Before publishing:
- run `deno task update` to update all dependencies including telo misikeke
- set parameters on `project-data.json`
- Remove details
- update this very document, don't forget to add release date
-->

<!--
Expand All @@ -15,14 +15,24 @@ On this on-development version, things can be broken.
</details>
-->

## 0.5.2

Released 14 March 2025

- Change "Add word" button into "Import word".

## 0.5.1

Released 9 Mar 2025

- Fix adverb placement within verbs: "sina o lape pona" can now translate into
"You should nicely sleep" instead of "You nicely should sleep".
- Fix "token is not defined" bug when telo misikeke error messages is turned on.

## 0.5.0

Released 9 Mar 2025

ilo Token can now translate "o" imperative sentences such as "o toki" and "mi o
lape".

Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@
"@std/regexp": "jsr:@std/regexp@^1.0.1",
"@std/text": "jsr:@std/text@^1.0.11",
"compromise": "npm:compromise@^14.14.3",
"esbuild": "npm:esbuild@^0.25.0"
"esbuild": "npm:esbuild@^0.25.1"
}
}
108 changes: 54 additions & 54 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dictionary/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ function lex<T>(parser: Parser<T>): Parser<T> {
const comment = match(/#[^\n\r]*/, "comment");
const spaces = sourceOnly(all(choiceOnlyOne(match(/\s/, "space"), comment)));
const backtick = matchString("`", "backtick");
const colon = matchString(":", "colon");

const tokiPonaWord = lex(match(/[a-z][a-zA-Z]*/, "word"));
const openParenthesis = lex(matchString("(", "open parenthesis"));
const closeParenthesis = lex(matchString(")", "close parenthesis"));
const openBracket = lex(matchString("[", "open bracket"));
const closeBracket = lex(matchString("]", "close bracket"));
const comma = lex(matchString(",", "comma"));
const colon = lex(matchString(":", "colon"));
const semicolon = lex(matchString(";", "semicolon"));
const slash = lex(matchString("/", "slash"));

Expand Down
8 changes: 8 additions & 0 deletions dictionary/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { assertMatch } from "@std/assert/match";
import { dictionary } from "./dictionary.ts";

Deno.test("definition source has leading space", () => {
for (const [word, { src }] of dictionary) {
assertMatch(src, /^\s/, `Error at ${word}`);
}
});
4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ <h1>
>(Help)</a>
</h1>
<div>
<input id="add-word" type="text" />
<button id="add-word-button">Add word</button>
<input id="import-word" type="text" />
<button id="import-word-button">Import word</button>
</div>
<textarea
id="custom-dictionary"
Expand Down
6 changes: 3 additions & 3 deletions project_data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.1",
"onDevelopment": false,
"releaseDate": "2025-3-9"
"version": "0.5.2",
"onDevelopment": true,
"releaseDate": "2025-3-14"
}
33 changes: 16 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ non-pu words. Just know that the
custom dictionary comes with
limitations. Press Help above to get
started.`;
const EMPTY_DEFINITION_PLACEHOLDER = "Definitions here";

const DICTIONARY_LOADING_FAILED_FIXABLE_MESSAGE =
"Failed to load custom dictionary. This is mostly likely because the " +
"syntax has been updated and your custom dictionary still uses the old " +
"syntax. Please fix it. Apologies for the inconvenience.";
const DICTIONARY_LOADING_FAILED_UNFIXABLE_MESSAGE =
"Failed to load custom dictionary. Please report this.";
const WORD_NOT_FOUND_MESSAGE = "Error: Word not found.";
const INVALID_WORD_ERROR =
"Error: Invalid word to add (You may remove this line).";
const DICTIONARY_ERROR_FIXABLE_MESSAGE =
Expand Down Expand Up @@ -100,11 +100,11 @@ function main(): void {
const customDictionaryDialogBox = document.getElementById(
"custom-dictionary-box",
) as HTMLDialogElement;
const addWordTextBox = document.getElementById(
"add-word",
const importWordTextBox = document.getElementById(
"import-word",
) as HTMLInputElement;
const addWordButton = document.getElementById(
"add-word-button",
const importWordButton = document.getElementById(
"import-word-button",
) as HTMLButtonElement;
const customDictionaryTextBox = document.getElementById(
"custom-dictionary",
Expand Down Expand Up @@ -240,11 +240,11 @@ function main(): void {
`${asComment(DEFAULT_CUSTOM_DICTIONARY_MESSAGE)}\n`;
}
});
addWordButton.addEventListener("click", addWord);
addWordTextBox.addEventListener("keydown", (event) => {
importWordButton.addEventListener("click", importWord);
importWordTextBox.addEventListener("keydown", (event) => {
if (event.code === "Enter" && !event.altKey && !event.shiftKey) {
event.preventDefault();
addWord();
importWord();
}
});
function displayToCustomDictionary(message: string): void {
Expand All @@ -254,16 +254,15 @@ function main(): void {
`${original}${append}${message.trimEnd()}\n`;
customDictionaryTextBox.scrollTo(0, customDictionaryTextBox.scrollHeight);
}
function addWord(): void {
const word = addWordTextBox.value.trim();
function importWord(): void {
const word = importWordTextBox.value.trim();
if (/^[a-z][a-zA-Z]*$/.test(word)) {
const dictionaryEntry = dictionary.get(word);
const definitions = dictionaryEntry?.src ??
`\n${
asComment(EMPTY_DEFINITION_PLACEHOLDER)
.replaceAll(/^/gm, " ")
}`;
displayToCustomDictionary(`${word}:${definitions}`);
const definitions = dictionary.get(word)?.src;
if (definitions != null) {
displayToCustomDictionary(`${word}:${definitions}`);
} else {
displayToCustomDictionary(asComment(WORD_NOT_FOUND_MESSAGE));
}
} else {
displayToCustomDictionary(asComment(INVALID_WORD_ERROR));
}
Expand Down