func readWordListInternal(
	lowercaser cases.Caser, chosenLanguage string,
	wordlistSupplier func(string) (string, error)) ([]string, error) {
	languageIdentifier := getLanguageIdentifier(chosenLanguage)
	words, available := wordListCache[languageIdentifier]
	if !available {
		wordListFile, supplierError := wordlistSupplier(languageIdentifier)
		if supplierError != nil {
			return nil, supplierError
		}
		words = regexp.MustCompile("\r?\n").Split(wordListFile, -1)
		for wordIndex, word := range words {
			words[wordIndex] = lowercaser.String(word)
		}
		wordListCache[languageIdentifier] = words
	}
	shuffledWords := make([]string, len(words))
	copy(shuffledWords, words)
	shuffleWordList(shuffledWords)
	return shuffledWords, nil
}
readWordListInternal exists for testing purposes, it allows passing a custom
wordListSupplier, in order to avoid having to write tests aggainst the
default language lists.
package game
import (
	"embed"
	"io"
	"math/rand"
	"regexp"
	"time"
	"golang.org/x/text/cases"
)
var (
	wordListCache       = make(map[string][]string)
	languageIdentifiers = map[string]string{
		"english_gb": "en_gb",
		"english":    "en_us",
		"italian":    "it",
		"german":     "de",
		"french":     "fr",
		"dutch":      "nl",
	}
	wordFS embed.FS
)
func getLanguageIdentifier(language string) string {
	return languageIdentifiers[language]
}