outr / powerscala

Powerful framework providing many useful utilities and features on top of the Scala language.
15 stars 6 forks source link

Add a `nativeNames: List[String]` value to org.powerscala.Language enumerations #11

Open Idyllei opened 7 years ago

Idyllei commented 7 years ago

Upon browsing the PowerScala source, I stumbled upon the Language.scala definition. I find it interesting that name variants are included in English, French, and German, but not in other languages--not even in the language itself.

It may be beneficial to add values for the name of the language as referred to by the speakers of the language itself. For example Spanish is "español" or "castillano", Greek is "ελληνικά", and Japanese is "日本語" or "にほんご”.

By adding these native names, one would be able to use this library for creating a "Select your language" drop-down list, or something similar.

For example, the definition might become:

sealed abstract class Language(val bibliographic: String
        val terminology: String,
        val iso639_1: Option[String],
        val englishNames: List[String],
        val frenchNames: List[String],
        val germanNames: List[String],
        // nativeNames is added
        val nativeNames: List[String]) extends EnumEntry {
  Language.init(this)
}

object Language extends Enum[Language] {
  private var lookup = Map.empty[String, Language]

  case object GreekModern extends Language("gre", "ell", Some("el"), List("Greek", "Greek, Modern (1453-)"), List("grec moderne (après 1453)"), List("Neugriechisch"), List("ελληνικά"))
  case object Japanese extends Language("jpn", "jpn", Some("ja"), List("Japanese"), List("japonais"), List("Japanisch"), List("日本語", "にほんご"))
  case object Spanish extends Language("spa", "spa", Some("es"), List("Spanish", "Castilian"), List("espagnol", "castillan"), List("Spanisch"), List("español", "castillano"))
  // ...
}
darkfrog26 commented 7 years ago

That's a good idea. Would you be willing to submit a PR to add that functionality?

Idyllei commented 7 years ago

I'll spend some time on putting it together. Thanks!