Scripts

To create a Japanizer dictionary you basically only need a text file with entries containing translations. A simple guide to create one is here.

When you have your japanizer/xml file prepared (and it has more than 100 entries) there is only one thing left. It has to have an options tag with correct number of groups. This tag describes groups of words that are simultaneously replaced on the page by Japanizer addon. You may have noticed, that in tutorial entries have an attribute named ‘s’. It denotes which group the entry belongs to. You don’t have to worry about all this if you are using our make script (actually xml_converter.py – which is run by make). It automatically calculates it for you. Basically it creates a group for every 108 words in the dictionary.

If you have even more words you’d like to use in your dictionary you might want to use one of our scripts: csv2xml. Just create a semicolon separated csv file with columns in order: translation; kanji; kana; romaji. If there is something wrong with your dictionary and you have some non standard characters in csv file you might try to put the values in double quotes.

You can also use anki2 files to make Japanizer dictionaries. There is anki2csv script that creates csv file based on columns you specify in command line. What it exactly does is it opens up specified anki2 file, gets ‘flds’ column from ‘notes’ table and splits it by given columns. The process is explained below.

There is an empty formats.anki2 file. It is used by make script to automatically parse anki2 files. This file contains column definitions for anki2 files. Each line should have path, colon and space separated columns. Columns describe the order of fields which contain particular values. E.g.

to_convert/Words.anki2:kanji kana meaning

make script will use it to run anki2csv as follows:

anki2csv -f to_convert/Words.anki2 -df columns -c kanji kana meaning > to_convert/Words.csv

which will create Words.csv file. Available column types can be obtained by typing ‘anki2csv -h’.

Beside that make script will also add missing titles (based on file names) and insert options tag. By default it will only convert anki2 files into csv if there is not already a coresponding csv file. Same goes for creating xmls from csvs and japanizer dictionaries from xmls. You can override this behavior by specifying 3 parameters.

usage: ./make [y|n] [y|n] [y|n] First parameter tells if csv files should be recreated (based on anki2 files)
Secon parameter tells if xml files should be recreated (based on csv files)
Third parameter tells if japanizer files should be recreated (based on xml files)

So to recreate xml and japanizer files you would type: ./make n y y

To use make script put all your ank2/csv/xml files into to_convert directory and run ‘./make’.

To download the package with scripts: japanizer-dictionary-create. You will need some bash and python knowledge to use them.