- support for different languages (set of tiles as well as the interface). Thanks to Wikipedia for providing data about tiles for each language (https://fr.wikipedia.org/wiki/Lettres_du_Scrabble)
For contributions, see (contributing)[CONTRIBUTING.md].
## Set up for production
Note: Please be aware that this is alpha-quality software.
We do our best to avoid breaking stuff but we might from time to time.
With this out of the way…
Trivabble is composed of two parts: the server and the client.
- The server is a Javascript program that runs on Node JS.
It waits for HTTP and WebSocket requests on a configurable port (default: 3000), and a configurable address (default: localhost).
This server needs to run for Trivabble to work, and proxified through a Web server like Apache or Nginx.
- The client is a set of static files that need to be server by a Web server
### Prerequisite
You need to have:
- Node (version 10 or later)
- make
- git
- a Web server such as Apache or Nginx.
On a Debian-based system, the following command will install make and node:
apt install make nodejs git
On some systems, the node binary does not exist and is called `nodejs` instead. Trivabble expects the Node binary to be `node`. On these systems, a `nodejs-legacy` package may exist to fix this. Otherwise, you will need to create a symblink.
As for the web server, we will asume that you already have one running and correctly configured.
### Installation
We will assume www-data is the UNIX user of your Web server. Adapt if necessary.
1. Set up the directories that will host the server and the client.
Create a UNIX user for the Trivabble server and set the right permission:
The server should be outside the root of your Web server.
The client will be served by your Web server.
Let's store the chosen paths in environment variables (adapt if necessary) and create these directories:
- run `make` so everything that needs to be build will be built, including the language files
- transform Javascript files so they are compatible with older browsers
- copy the server and client files to the chosen folders
6. (Optional) - In the public directory (`$TRIVABBLE_PUBLIC_PATH`), review `config.js.sample`. If there are values you would like to change, copy it to config.js and make the desired changes.
7. Run the Trivabble server.
```sh
cd "$TRIVABBLE_SERVER_PATH"
node trivabble-server
```
You may want to run this in a `screen` so you can leave the session and trivabble-server still runs in the background.
Better yet, create a service for your init system:
If you want to limit spelling to a subset of languages, you can define the list by the `LANGS` variable before executing the `make` command such as:
```sh
cd dict-dists-extractor
LANGS="de en fr" make
```
This way, you only build English, French and German dictionaries.
To deactivate spell checker at system level, you need to empty dictionary list contained into file `public/dict/list.js`. Such command can be used:
```sh
echo > public/dict/list.js
```
## Technical appendices
### Board extractor
Wikipedia provides tile distributions (content of the bag and points) for various languages. Board languages are built from a Wikipedia page.
#### General parsing
Most board languages are extracted from the French version of the Wikipedia page which has a simple document structure. Parsing is done by a JS script named `make_board.js`:
- each new language board is proceeded by a level 2 header containing language name,
- tile points is followed by `point(s)`
- tile letter and number of tiles are easy extracted by a regex which looks like `<b>(letter)</b> <small>x(times)</small>`
#### Special languages
Some languages are only defined into the English version. So we copy them into separated text files and parsing is done by an AWK named `make_board.awk`.
### Dictionary building process
The spell checker in Trivabble is based on Aspell dictionaries. However, as Trivabble only uses a subset of letters (most accentuated characters have to be replaced by standard ones), we can't use Aspell engine straightforward; we need to build lists of words that only use playable characters.
#### Overall concept
In order to build dictionaries for various languages, we first need to retrieve Aspell dictionary lists. Then we retrieve the last versions of dictionaries for every languages and we build them. Thanks to two Aspell commands, we build the full list of words. Based on the distribution of tiles, we translate every derived (most of the time accentuated) character by the appropriate one, and finally we remove duplicated entries.
#### Details on Makefile rules
Rule '$(OBJ_DIR)/src.mk' retrieves on Aspell site the last version of the dictionary list, extract dictionary archive URL and build a sub-makefile with rules to retrieve every needed dictionary.
Rule '%.dir' unpacks dictionary archives and build Aspell dictionary. Result directory is rename as LANG.dir
Rule '%.low' expands a Aspell dictionary into a list of words (low means "List Of Words"". Phrases are split into words. Finally the list is ordered and clean from duplicated words.
Rule '$(ROOT_DICT)/%.dict':
- excludes words with numbers, dashes, apostrophes and other forbidden signs,
- translates accentuated characters into standard ones,
- up-case all words,
- and remove duplicated words.
This file can be used by Trivabble for spell checking.
Last rule 'check-%' checks that file %.dict contains only words with characters base on language tile bag.
#### Remarks
Some lists of words are too huge (for example Hungarian or Turkish are agglutinative languages), so Trivabble will not be able to check spelling for those languages.