This problem might be better handled with a static enum, as it gives you a
typeclass and also language specific dispatch.
type
Locale = enum
Unknown, English, French
Language[T: static Locale] = distinct string
proc readFile(path: string; locale: static Locale = Unknown):
Language[locale] =
echo "Lang: ", locale, ", path: ", path
Language[locale]("") # dummy
proc `$`(lang: Language): string = string(lang) # Devel has a fix for
borrowing typeclasses like this, but before needs this.
discard readFile("english.txt", English)
discard readFile("french.txt", French)
discard readFile("we_dont_know_what_language_at_compile_time.txt", Unknown)
discard readFile("we_dont_know_what_language_at_compile_time.txt")
Run