MessagesIntegrity

io.github.frikit.twirlspec.messages.MessagesIntegrity

Checks over a service's message files.

Attributes

Source
MessagesIntegrity.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final case class Config(baseLanguage: String = ..., requireTranslations: Boolean = ..., maxUntranslatedRatio: Double = ..., ignoreKeys: Set[String] = ..., ignoreKeyPrefixes: Set[String] = ..., urlKeySuffixes: Set[String] = ...)

What the checks measure against, and what they leave alone.

What the checks measure against, and what they leave alone.

Value parameters

baseLanguage

the language the others are measured against: Play's default file plus this one

ignoreKeyPrefixes

prefixes of keys left out of every check

ignoreKeys

keys left out of every check

maxUntranslatedRatio

how much of a translation may be identical to the base before it is treated as untranslated

requireTranslations

whether every other configured language must carry every base key; off for a single-language service

urlKeySuffixes

suffixes of keys whose value is a URL, expected to read the same in every language and so not counted as untranslated

Attributes

Companion
object
Source
MessagesIntegrity.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Config

The default configuration.

The default configuration.

Attributes

Companion
class
Source
MessagesIntegrity.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Config.type

Value members

Concrete methods

def baseMessages(api: MessagesApi, config: Config = ...): Map[String, String]

The base language's messages: Play's default file plus the file for the base code.

The base language's messages: Play's default file plus the file for the base code.

Attributes

Source
MessagesIntegrity.scala
def check(api: MessagesApi, config: Config = ...): Seq[Violation]

Every problem across the message files.

Every problem across the message files.

Attributes

Source
MessagesIntegrity.scala
def duplicateKeys(files: Seq[File]): Seq[Violation]

Keys defined more than once in a single messages file. A file that is not there, or no files at all, is a finding: nothing was checked, and a wrong path would otherwise pass for ever.

Keys defined more than once in a single messages file. A file that is not there, or no files at all, is a finding: nothing was checked, and a wrong path would otherwise pass for ever.

Attributes

Source
MessagesIntegrity.scala
def messagesFor(api: MessagesApi, langCode: String): Map[String, String]

The messages of one language, empty when the api holds none for it.

The messages of one language, empty when the api holds none for it.

Attributes

Source
MessagesIntegrity.scala
def translationLanguages(api: MessagesApi, config: Config = ...): List[String]

Every language the api holds messages for, other than the base.

Every language the api holds messages for, other than the base.

Play keeps its own framework messages under default.play, alongside the service's default file. Neither is a language.

Attributes

Source
MessagesIntegrity.scala