openbibleinfo / Bible-Passage-Reference-Parser

Coffeescript to identify and understand Bible references like "John 3:16."
223 stars 65 forks source link

Translations #12

Closed vincenzo closed 9 years ago

vincenzo commented 9 years ago

Hi again, @openbibleinfo.

First of all, thanks for open-sourcing this. It's already being very useful for me to build some kind of RefTagger that works with Italian.

I hope you wouldn't mind explaining a bit the structure used in the translations.coffe file? I am trying to figure out how to add the most popular Italian protestant translations to the file (I'll contribute it back, when I'll manage to get it right), since none of them are there.

Thanks for any help.

Cheers,

Vince

openbibleinfo commented 9 years ago

Are you looking to add just the abbreviation names, or do you also want to change the number of books/chapters/verses in certain of the translations you're adding? In either case, translations.coffee is a generated file, so you won't be editing it directly.

vincenzo commented 9 years ago

At the moment I am building something really basic: it replaces every occurrence of a Bible reference on the page with a Bible Gateway search link to the same. So "Giovanni 2:13" (that's John, btw) becomes Giovanni 2:13 (translation NR2006 is assumed by default). If it encounters "Giovanni 2:13 LND", then it should turn that in this other link: Giovanni 2:13 LND.

At the moment I've achieved this in a slightly hacky way: I edited the translations regexp in it_bcv_parser.js to look like this:

bcv_parser.prototype.regexps.translations = /(?:(?:CEI|NR2006|NR1994|LND|N[RD]))\b/gi;

so that now it matches the translations, too. It's actually working just fine now.

I am not really concerned at the moment with books/chapters/verses, although, if I were to do this properly, then there are verse numbering variations between the NR* versions and the LND for example. The CEI is a Catholic Bible, so it also contains the Aprocrypha, but that's already accounted for. There are other (older) variations I am not interested to add at this stage. Plus a "New Testament"-only translation I may want to add.

I suppose, though, I should be doing this right and regenerate the .coffee file. I won't be ashamed to say I don't know where to start. Never done anything with Coffeescript.

openbibleinfo commented 9 years ago

Editing that RegExp will produce exactly what you need.

The short build instructions are, from the bin folder, run:

perl 01.add_lang.pl it perl 02.compile.pl it

These scripts assume that you have the requisite Perl modules installed, as well as the coffee and pegjs binaries installed (using npm install -g).

I've never tried running these scripts on any computer besides my own, so I'm not sure how well they travel.