Papyrix includes a support library (integrated into its fancier text layout) for auto-hyphenating words, finding all the place might be hyphenated. So how does it work?
There's a public API which reformats the results from its auto-hyphenation & exposing the language-setter.
That setter invokes which helper which strips the region off the language-code & converts ISO639-2 into into ISO639-1 codes via lookuptable, to get the appropriate hyphenation data via another lookuptable.
1/?
Meanwhile to compute break offsets Papyrix validates it has a word to process, reformats the text (via a helper in another file) into UTF-32 annotated with UTF-8 offsets, parses off surrounding punctuation & footnotes, locates various forms of hyphens & contiguous latin characters into the tentative results, if data's available iterates over the codepoints sorting & deduplicating results, otherwise defers to a method on the hyphenator or breaks on all chars in centre of the word.
2/?