Skip to content

Commit

Permalink
Release v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
salif committed Aug 23, 2024
1 parent c76b79f commit d976964
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 254 deletions.
Empty file added .nojekyll
Empty file.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021,2024 Salif Mehmed
Copyright 2021,2024 Salif Mehmed

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
62 changes: 43 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@

## Links

* [Homepage](https://salif.github.io/morse-code-translator/)
* [Web tool](https://salif.github.io/morse-code-translator/)
* [Source code](https://codeberg.org/salif/morse-code-translator)
* [Discussions (Github)](https://github.com/salif/morse-code-translator/discussions)

## Usage
## Gleam library

### Installation

```sh
gleam add morse_code_translator
gleam add morse_code_translator@2
```

### Usage

```gleam
import gleam/io
import gleam/option.{None, Some}
import gleam/result
import morse_code_translator as mct
pub fn main() {
Expand All @@ -28,7 +33,7 @@ pub fn main() {
output_space: None,
output_separator: None,
is_uppercase: None,
language_num: None,
language: None,
)
let demo_decode_options =
Expand All @@ -38,35 +43,35 @@ pub fn main() {
input_space: None,
input_separator: None,
to_uppercase: None,
language_num: None,
language: None,
)
let demo_encode: Result(String, mct.MorseCodeError) =
mct.encode(" Test ", demo_encode_options, None)
io.debug(demo_encode)
// Ok("/ - . ... - /")
" Test "
|> mct.encode(demo_encode_options, None)
|> result.map(io.println)
// "/ - . ... - /"
let demo_decode: Result(String, mct.MorseCodeError) =
mct.decode("/ - . ... - /", demo_decode_options, None)
io.debug(demo_decode)
// Ok(" test ")
"/ - . ... - /"
|> mct.decode(demo_decode_options, None)
|> result.map(io.println)
// " test "
"demo"
|> mct.encode_to_string(demo_encode_options, None)
|> mct.decode_to_string(demo_decode_options, None)
|> io.debug
|> io.println
// "demo"
"_.. . __ ___"
|> mct.decode_to_string(
mct.DecodeOptions(
..demo_decode_options,
input_dash: Some("_"),
language_num: Some(mct.language_num_cyrillic),
language: Some(mct.language_cyrillic),
),
None,
)
|> io.debug
|> io.println
// "демо"
let demo_convert_options =
Expand All @@ -83,20 +88,39 @@ pub fn main() {
"-.. . -- ---"
|> mct.convert(demo_convert_options)
|> io.debug
// Ok("100 0 11 111")
|> result.map(io.println)
// "100 0 11 111"
"="
|> mct.convert_to_string(demo_convert_options)
|> io.debug
|> io.println
// "Invalid morse code symbol: ="
}
```

### Version 2.2.0

Version `2.2.0` contains backward incompatible changes.
If you are using `EncodeOptions` and `DecodeOptions`, change `language_num` to `language`.

Further documentation can be found at <https://hexdocs.pm/morse_code_translator>.

## Web tool

### Add new page language

Open `index.html` and find all occurrences of `set_page_language`, `data-lo=`
and `dataset.lo =`, then add translations and send a pull request.

### Manually set page language

Use <a href="javascript:(function(){window.set_page_language(window.prompt('Enter language code')??'');})()">this bookmarklet</a>, save it as bookmark, then open it at the web page.


## Development

```sh
# just format
just build
just serve
```
5 changes: 2 additions & 3 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name = "morse_code_translator"
version = "2.1.0"
version = "2.2.0"

description = "Morse Code Translator"
licences = ["MIT"]
links = [
{title = "Website", href = "https://salif.github.io/morse-code-translator"},
{title = "Web tool", href = "https://salif.github.io/morse-code-translator/"},
{title = "Github", href = "https://github.com/salif/morse-code-translator"},
]
repository = {type = "codeberg", user = "salif", repo = "morse-code-translator"}
target = "javascript"

[dependencies]
gleam_stdlib = ">= 0.39.0 and < 1.0.0"
Expand Down
Loading

0 comments on commit d976964

Please sign in to comment.