Commit e4f9cfa5 authored by Siltaar's avatar Siltaar
Browse files

more doc

parent bb739df9
= month_nb : get the number of a month
= month_nb : get the number of a month from its name
`month_nb.js` is a small utility which knows the corresponding number of a month
name, in 69 https://en.wiktionary.org/wiki/Appendix:Months_of_the_year[languages].
......@@ -10,23 +10,25 @@ Usage:
8
```
The function returns month number from a given litteral case-insensitive month
name or abbreviation.
The function returns a month number from a given litteral case-insensitive month
name or abbreviation. It returns `undefined` if no corresponding number is found.
It's currently presented as plain JavaScript files
== Architecture
`month_nb.js` only contains a loop going through a JSON tree data structure
made of regular expression strings as keys (or nodes), sub-objects as branchs,
and numbers as leafs. The data structure itself resides in the
made of regular expression strings as keys (for the nodes), sub-objects as
branchs and numbers as leafs. The data structure itself resides in the
`month_nb_json.js` file.
This clear separation between code and data makes it possible to use
`month_nb_json.js` data structure with other languages to reimplement
`month_nb`.
This clear separation between code and data is wanted to ease the re-use of
`month_nb_json.js` data structure with other languages, to reimplement a
`month_nb` feature.
== Status
== Supported languages
`month_nb.js` works for 69 languages (including most living written languages),
but there two ambiguities :
......@@ -36,30 +38,33 @@ but there two ambiguities :
Support for those languages were postponed : Chechen, Cherokee, Hawaiian, Lezgi,
Navajo, Ojibwe, Old English, Old High German, Old Norse.
== Character encoding considerations
Currently the `month_nb_json.js` tree data structure is filled with UTF-8
characters (like "é"). It's easy to read but can prove complicated to edit,
specifically with right-to-left characters mixed with left-to-right ones, or
with aggregated characters to form one symbol that we need to cut in the middle
and end up aggregating with a closing parenthesis or quote.
with aggregating characters (combining in one symbol) separated by copy/pastes
and than end up aggregating with a closing parenthesis or a quote.
Converting every UTF-8 character to the `\u00E9` form might help other
programming languages to use it (but would complicate the next editions of the
tree).
programming languages to re-use it (but would complicate the maintenance of
the tree).
== Running tests
To test `month_nb.js` against all the languages, run :
To test `month_nb.js` against the language definition file, run :
```sh
$ phantomjs driver_test_month_nb.js
```
You may have to install the `phantomjs` package on Debian.
The `phantomjs` command comes from the eponymous package on Debian.
It will display various information about working languages and possible
errors. More information can be displayed changing the default values
arguments of the `test()` function of the `test_month_nb.js` file.
It will display various informations about the working languages and possible
errors. More information can be displayed changing the default value of
arguments of the `test()` function in the `test_month_nb.js` file.
== TODO
......@@ -79,3 +84,6 @@ $ wget https://en.wiktionary.org/wiki/Appendix:Months_of_the_year
Then, running the `month_nb` tests shows a lot of work.
=== Node packaging
Make a NodeJS package out of it.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment