gleam add morse_code_translator@2
import gleam/io
import gleam/option.{None, Some}
import gleam/result
import morse_code_translator as mct
pub fn main() {
let demo_encode_options =
mct.EncodeOptions(
output_dot: None,
output_dash: None,
output_space: None,
output_separator: None,
is_uppercase: None,
language: None,
)
let demo_decode_options =
mct.DecodeOptions(
input_dot: None,
input_dash: None,
input_space: None,
input_separator: None,
to_uppercase: None,
language: None,
skip_invalid_symbols: None,
)
" Test "
|> mct.encode(demo_encode_options, None)
|> result.map(io.println)
// "/ - . ... - /"
"/ - . ... - /"
|> 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.println
// "demo"
"_.. . __ ___"
|> mct.decode_to_string(
mct.DecodeOptions(
..demo_decode_options,
input_dash: Some("_"),
language: Some(mct.language_cyrillic),
),
None,
)
|> io.println
// "демо"
let demo_convert_options =
mct.ConvertOptions(
input_dot: mct.default_dot,
output_dot: "0",
input_dash: mct.default_dash,
output_dash: "1",
input_space: mct.default_space,
output_space: mct.default_space,
input_separator: mct.default_separator,
output_separator: mct.default_separator,
)
"-.. . -- ---"
|> mct.convert(demo_convert_options)
|> result.map(io.println)
// "100 0 11 111"
"="
|> mct.convert_to_string(demo_convert_options)
|> io.println
// "Invalid morse code symbol: ="
}
Further documentation can be found at https://hexdocs.pm/morse_code_translator.
Version 2.2.0
contains backward incompatible changes.
If you are using EncodeOptions
and DecodeOptions
, change language_num
to language
.
Use this bookmarklet, save it as a bookmark, then open it while on the web page:
javascript:(function(){window.mct.set_page_language(window.prompt('Enter language code')??'');})()
Open index.html
and find all occurrences of set_page_language
, data-lo=
and dataset.lo =
, then add translations and send a pull request.
# just format
just build
just serve