TranslatablePair

Represents key-value pair from Localizable.strings files. It contains key, value and expression if exists for the key. It can also validate if text matches expression’s requirements.

  • key

    Key from Localizable.strings.

    Declaration

    Swift

    var key: Key
  • Value from Localizable.strings.

    Declaration

    Swift

    var value: Value
  • Expression which is parsed from key.

    Declaration

    Swift

    var expression: Expression? = nil
  • Tells if pair has expression or not.

    Declaration

    Swift

    var hasExpression: Bool { return expression != nil }
  • It returns key without expression pattern. If pair has expression set to nil it will return key. If expression exist the key will be parsed and returned without expression pattern.

    Declaration

    Swift

    var keyWithoutExpression: String
  • Creates TranslatablePair. It automatically tries to parse expression from key - if there is any.

    Declaration

    Swift

    init(key: Key, value: Value)

    Parameters

    key

    A key from Localizable.strings

    value

    A value from Localizable.strings

  • Method parses expression from the key property.

    Declaration

    Swift

    mutating func parseExpression()
  • Validates string and check if matches expression’s requirements. If pair has no expression it return false.

    Declaration

    Swift

    func validate(value: String) -> Bool

    Parameters

    value

    A value that will be matched.

    Return Value

    true if value matches expression, otherwise false.