Class: Locallingo::Validators::Missing

Inherits:
Object
  • Object
show all
Defined in:
lib/locallingo/validators/missing.rb

Overview

Reports keys present in the source locale but absent from a target locale.

Instance Method Summary collapse

Constructor Details

#initialize(cli_name: "lingo") ⇒ Missing

Returns a new instance of Missing.



7
8
9
# File 'lib/locallingo/validators/missing.rb', line 7

def initialize(cli_name: "lingo")
  @cli_name = cli_name
end

Instance Method Details

#call(source:, target:, locale:) ⇒ Object

source and target are flat key=>value hashes for one target locale.



12
13
14
15
16
17
18
19
20
21
# File 'lib/locallingo/validators/missing.rb', line 12

def call(source:, target:, locale:)
  (source.keys - target.keys).map do |key|
    {
      type: :missing,
      locale:,
      key:,
      suggestion: "Run: #{@cli_name} translate --locale #{locale}"
    }
  end
end