diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml new file mode 100644 index 0000000..168c933 --- /dev/null +++ b/.github/workflows/deno.yml @@ -0,0 +1,34 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will install Deno then run `deno lint` and `deno test`. +# For more information see: https://github.com/denoland/setup-deno + +name: Deno + +on: + push: + branches: ["release"] + pull_request: + branches: ["release"] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Setup repo + uses: actions/checkout@v3 + + - name: Setup Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Build + run: deno task build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9b203a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +main.js diff --git a/.vscode/settings.json b/.vscode/settings.json index 4533aed..e7c316b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,11 @@ { - "cSpell.customDictionaries": { - "ku-suli": { - "name": "ku-suli", - "path": "${workspaceRoot}/nimi-ku-suli.txt", - "description": "Ku Suli words of Toki Pona", - "addWords": true - } + "cSpell.customDictionaries": { + "ku-suli": { + "name": "ku-suli", + "path": "${workspaceRoot}/nimi-ku-suli.txt", + "description": "Ku Suli words of Toki Pona", + "addWords": true } -} \ No newline at end of file + }, + "deno.enable": true +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8778093..b9c5d86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,35 @@ # Changelog +## 0.2.0 + +For this version. The whole code has been rewritten. The translator can now translate few more things! Although it's still not capable of translating full sentences. + +- Implement translator for: + - Extended numbering system + - Reduplication + - _nanpa_ particle + - _en_ and _anu_ +- Add button for translating, replacing auto-translate when typing. +- (Downgrade) Drop support for "a" particle. +- (Downgrade) Error messages are now very unreliable. +- (Downgrade) Translator is somewhat slower. +- Remove Discord DM as contact option. +- Update translation list: + - _tonsi_ – change nouns "transgender", "transgenders", "non-binary", and "non-binaries" into "transgender person", "transgender people", "non-binary person", and "non-binary people" (I DIDN'T MEAN TO OBJECTIFY THEM OMFG I'M SO SORRY 😭😭😭) + +Inside update (intended for developers): + +- Rewritten whole code to use TypeScript, module, and functional programming. +- Rewritten parser to use parser combinator. +- Add language codes to html. +- New wiki for contributors and thinkerers. +- Overhaul `README.md`, only including build instruction. Information about the translator is now moved to wiki. + ## 0.1.1 -- Update copyright notice -- Update version number on the page -- Update contacts to discord (from `neverRare#1517` to `never_rare`) +- Update copyright notice. +- Update version number on the page. +- Update contacts to Discord. (from `neverRare#1517` to `never_rare`) ## 0.1.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3a12db0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Contributing + +You can do the usual github stuff: Open issue if there's an issue or you have a suggestion; Open pull request if you want to propose changes. If you want to propose a large change however, please open an issue first (or comment on an already existing issue page), and wait for my signal before beginning to work. + +## The wiki + +The wiki provides useful information for contributors, although it's not complete yet. Check it out: [Visit wiki](https://github.com/neverRare/toki-pona-translator/wiki). diff --git a/LICENSE b/LICENSE index 92f17bc..0a5db1a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 neverRare +Copyright (c) 2024 neverRare Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 62754b8..dcffb2a 100644 --- a/README.md +++ b/README.md @@ -4,65 +4,16 @@ An imperfect Toki Pona to English translator that translates into multiple sente [Try it](https://neverrare.github.io/toki-pona-translator/) -## Goals +## Building -The goals for this projects are: +You'll need [Deno](https://deno.com/). Run the following command. -- Provide translation that covers most of semantics and meaning of a Toki Pona sentence, but it doesn't have to be complete. This gives translations for users to scan into to give them a feel of how broad a Toki Pona sentence can mean. -- As much as possible, provide translations that are grammatically sound: not just correct but also feels right. For example, "red one thing" sounds off than "one red thing". Due to the difference of English and Toki Pona and nuances of English, the translator may fall severely short for this goal, but we can try! +``` +git clone https://github.com/neverRare/toki-pona-translator.git +cd toki-pona-translator +deno task build +``` -## Non-goals +Then open `./index.html` using your favorite browser. -- Provide every possible translations. -- Handle every edge cases of Toki Pona grammar. Some edge cases are listed in [limitations] along with others. -- Handle compounds such as translating "tomo tawa" into "vehicle" -- Translate Tokiponized proper word into what it was before such as translating "Manka" into "Minecraft" - -Some of these may be lifted in the future. - -## Terminology - -These are the terminology used in [limitations] - -- Headword – A single part of speech that in English, can be a noun, a verb, or an adjective; what the phrase starts with. -- Modifier – A part of speech that modifies headword or another modifier. -- Phrase – Headword and its modifiers. -- Clause – A part of sentence without "la" particle, "taso" particle in the beginning, "a" particles in the beginning and the end; found before and after "la", or the sentence itself without particles around it if it doesn't have "la". -- Proper Word – Proper name; Capitalized in Toki Pona. - -## Limitations - -[limitations]: #limitations - -The following are currently unrecognized (non-definitive but pedantic). - -- Full sentences: It can only translate phrases for now. The following limitations pretends the translator can translate full sentences, this is because these are planned limitations. -- Non-pu vocabulary with exception to "pu" ("tonsi" is included in the vocabulary) -- Multiple sentences -- Comma as sentence separator (commas are treated as decoration and ignored) -- Proper word as headword -- Having multiple consecutive "a"s inside a sentence (in the beginning or end is fine) -- "taso" as headword ("taso" is currently recognized as modifier or particle at the beginning of a sentence) -- Having no clause before or after "la" particle -- "mi/sina li (pred)" constructions -- "mi/sina (pred) li (pred)" constructions (this would be recognized as "mi (modifier) li (pred)") -- "mi/sina a (pred)" constructions -- Clause with both "li" and "o" -- Clause with multiple "o"s -- Clause with "en" but without predicate ("li" or "o") -- "nanpa" as ordinal particle -- Extended numbering system -- "kepeken" as headword or modifier -- Multiple "pi" on a phrase -- "pi" followed by at most one modifier -- Multiple separate proper word on a single phrase, unless they're separated by "pi" (Proper words spanning multiple words like "musi Manka Sawa" is fine, this limitation refers to something like "musi Manka pona Sawa"; something like "musi Manka pi kule Sawa" is fine) -- proper word followed by "pi" -- "anu" particle -- "la a" -- "en a" -- "li a" -- "o a" -- "e a" -- "pi a" - -Some of these may be lifted in the future. +Whenever you made changes to `./src/*.ts`, you'll need to run `deno task build` again and refresh the browser. Later I'll make a script to automate this. diff --git a/bundle.ts b/bundle.ts new file mode 100644 index 0000000..a2e0554 --- /dev/null +++ b/bundle.ts @@ -0,0 +1,10 @@ +import { bundle } from "https://deno.land/x/emit@0.34.0/mod.ts"; + +const SOURCE = "./src/main.ts"; +const DESTINATION = "./main.js"; + +const url = new URL(SOURCE, import.meta.url); +const result = await bundle(url); + +const { code } = result; +await Deno.writeTextFile(DESTINATION, code); diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..52fee3f --- /dev/null +++ b/deno.json @@ -0,0 +1,16 @@ +{ + "lock": false, + "compilerOptions": { + "target": "esnext", + "lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"] + }, + "tasks": { + "build": "deno run --allow-read --allow-write --allow-env ./bundle.ts" + }, + "fmt": { + "include": ["./src/**/*.ts", "./bundle.ts", "./test-parser.ts"] + }, + "lint": { + "include": ["./src/**/*.ts", "./bundle.ts", "./test-parser.ts"] + } +} diff --git a/index.html b/index.html index e71bb0a..b84283d 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - + @@ -24,11 +24,15 @@

Toki Pona Translator

An imperfect Toki Pona to English translator that translates into multiple sentences. - Limitations.

- + +
+ +

@@ -51,7 +55,6 @@

Toki Pona Translator

>Toki Pona to multiple English sentence translator. -
  • Dm me on Discord: never_rare
  • Email me: Toki Pona Translator