Skip to content

Commit fd97c8f

Browse files
authored
Merge pull request #74 from ilo-token/master
0.5.2
2 parents 3d83677 + 56e05ed commit fd97c8f

File tree

8 files changed

+96
-79
lines changed

8 files changed

+96
-79
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
NOTE: Before publishing:
55
- run `deno task update` to update all dependencies including telo misikeke
66
- set parameters on `project-data.json`
7-
- Remove details
7+
- update this very document, don't forget to add release date
88
-->
99

1010
<!--
@@ -15,14 +15,24 @@ On this on-development version, things can be broken.
1515
</details>
1616
-->
1717

18+
## 0.5.2
19+
20+
Released 14 March 2025
21+
22+
- Change "Add word" button into "Import word".
23+
1824
## 0.5.1
1925

26+
Released 9 Mar 2025
27+
2028
- Fix adverb placement within verbs: "sina o lape pona" can now translate into
2129
"You should nicely sleep" instead of "You nicely should sleep".
2230
- Fix "token is not defined" bug when telo misikeke error messages is turned on.
2331

2432
## 0.5.0
2533

34+
Released 9 Mar 2025
35+
2636
ilo Token can now translate "o" imperative sentences such as "o toki" and "mi o
2737
lape".
2838

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
"@std/regexp": "jsr:@std/regexp@^1.0.1",
6363
"@std/text": "jsr:@std/text@^1.0.11",
6464
"compromise": "npm:compromise@^14.14.3",
65-
"esbuild": "npm:esbuild@^0.25.0"
65+
"esbuild": "npm:esbuild@^0.25.1"
6666
}
6767
}

deno.lock

Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dictionary/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ function lex<T>(parser: Parser<T>): Parser<T> {
4242
const comment = match(/#[^\n\r]*/, "comment");
4343
const spaces = sourceOnly(all(choiceOnlyOne(match(/\s/, "space"), comment)));
4444
const backtick = matchString("`", "backtick");
45+
const colon = matchString(":", "colon");
4546

4647
const tokiPonaWord = lex(match(/[a-z][a-zA-Z]*/, "word"));
4748
const openParenthesis = lex(matchString("(", "open parenthesis"));
4849
const closeParenthesis = lex(matchString(")", "close parenthesis"));
4950
const openBracket = lex(matchString("[", "open bracket"));
5051
const closeBracket = lex(matchString("]", "close bracket"));
5152
const comma = lex(matchString(",", "comma"));
52-
const colon = lex(matchString(":", "colon"));
5353
const semicolon = lex(matchString(";", "semicolon"));
5454
const slash = lex(matchString("/", "slash"));
5555

dictionary/test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { assertMatch } from "@std/assert/match";
2+
import { dictionary } from "./dictionary.ts";
3+
4+
Deno.test("definition source has leading space", () => {
5+
for (const [word, { src }] of dictionary) {
6+
assertMatch(src, /^\s/, `Error at ${word}`);
7+
}
8+
});

dist/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ <h1>
144144
>(Help)</a>
145145
</h1>
146146
<div>
147-
<input id="add-word" type="text" />
148-
<button id="add-word-button">Add word</button>
147+
<input id="import-word" type="text" />
148+
<button id="import-word-button">Import word</button>
149149
</div>
150150
<textarea
151151
id="custom-dictionary"

project_data.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.5.1",
3-
"onDevelopment": false,
4-
"releaseDate": "2025-3-9"
2+
"version": "0.5.2",
3+
"onDevelopment": true,
4+
"releaseDate": "2025-3-14"
55
}

src/main.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ non-pu words. Just know that the
4242
custom dictionary comes with
4343
limitations. Press Help above to get
4444
started.`;
45-
const EMPTY_DEFINITION_PLACEHOLDER = "Definitions here";
4645

4746
const DICTIONARY_LOADING_FAILED_FIXABLE_MESSAGE =
4847
"Failed to load custom dictionary. This is mostly likely because the " +
4948
"syntax has been updated and your custom dictionary still uses the old " +
5049
"syntax. Please fix it. Apologies for the inconvenience.";
5150
const DICTIONARY_LOADING_FAILED_UNFIXABLE_MESSAGE =
5251
"Failed to load custom dictionary. Please report this.";
52+
const WORD_NOT_FOUND_MESSAGE = "Error: Word not found.";
5353
const INVALID_WORD_ERROR =
5454
"Error: Invalid word to add (You may remove this line).";
5555
const DICTIONARY_ERROR_FIXABLE_MESSAGE =
@@ -100,11 +100,11 @@ function main(): void {
100100
const customDictionaryDialogBox = document.getElementById(
101101
"custom-dictionary-box",
102102
) as HTMLDialogElement;
103-
const addWordTextBox = document.getElementById(
104-
"add-word",
103+
const importWordTextBox = document.getElementById(
104+
"import-word",
105105
) as HTMLInputElement;
106-
const addWordButton = document.getElementById(
107-
"add-word-button",
106+
const importWordButton = document.getElementById(
107+
"import-word-button",
108108
) as HTMLButtonElement;
109109
const customDictionaryTextBox = document.getElementById(
110110
"custom-dictionary",
@@ -240,11 +240,11 @@ function main(): void {
240240
`${asComment(DEFAULT_CUSTOM_DICTIONARY_MESSAGE)}\n`;
241241
}
242242
});
243-
addWordButton.addEventListener("click", addWord);
244-
addWordTextBox.addEventListener("keydown", (event) => {
243+
importWordButton.addEventListener("click", importWord);
244+
importWordTextBox.addEventListener("keydown", (event) => {
245245
if (event.code === "Enter" && !event.altKey && !event.shiftKey) {
246246
event.preventDefault();
247-
addWord();
247+
importWord();
248248
}
249249
});
250250
function displayToCustomDictionary(message: string): void {
@@ -254,16 +254,15 @@ function main(): void {
254254
`${original}${append}${message.trimEnd()}\n`;
255255
customDictionaryTextBox.scrollTo(0, customDictionaryTextBox.scrollHeight);
256256
}
257-
function addWord(): void {
258-
const word = addWordTextBox.value.trim();
257+
function importWord(): void {
258+
const word = importWordTextBox.value.trim();
259259
if (/^[a-z][a-zA-Z]*$/.test(word)) {
260-
const dictionaryEntry = dictionary.get(word);
261-
const definitions = dictionaryEntry?.src ??
262-
`\n${
263-
asComment(EMPTY_DEFINITION_PLACEHOLDER)
264-
.replaceAll(/^/gm, " ")
265-
}`;
266-
displayToCustomDictionary(`${word}:${definitions}`);
260+
const definitions = dictionary.get(word)?.src;
261+
if (definitions != null) {
262+
displayToCustomDictionary(`${word}:${definitions}`);
263+
} else {
264+
displayToCustomDictionary(asComment(WORD_NOT_FOUND_MESSAGE));
265+
}
267266
} else {
268267
displayToCustomDictionary(asComment(INVALID_WORD_ERROR));
269268
}

0 commit comments

Comments
 (0)