Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/localer
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "thor"
require "irb"
require "json"
require_relative "../lib/localer"

module Localer
Expand All @@ -11,6 +12,7 @@ module Localer
say Localer::VERSION
end

option :json
desc "check [/path/to/rails/application]", "Check missing translations"
def check(app_path = Localer::Config::APP_PATH)
Localer.configure(options.dup.merge(app_path: app_path))
Expand All @@ -21,6 +23,7 @@ module Localer
say "\xE2\x9C\x94 No missing translations found.", :green
else
missing_translations = Localer.data.missing_translations
File.open(options[:json], 'w') { |f| JSON.dump(missing_translations, f) } if options[:json]
say "\xE2\x9C\x96 Missing translations found (#{missing_translations.count}):", :red
missing_translations.each do |tr|
say "* #{tr}"
Expand Down
13 changes: 13 additions & 0 deletions features/simple.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ Scenario: Empty en locale
When I run checker
Then the checker should fail

Scenario: Empty en locale creates a json dump
Given a "ru" locale file with:
"""
ru:
one: один
"""
When I run checker with json
Then the checker should fail
And the checker should create a json dump with:
"""
["en.one","us.one"]
"""

Scenario: Incorrect structure
Given a "en" locale file with:
"""
Expand Down
10 changes: 10 additions & 0 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
step 'the exit status should be 1'
end

Then /^the checker should create a json dump with:$/ do |file_content|
file_name = 'tmp/aruba/output.json'
output = File.exist?(file_name) ? File.read(file_name) : ''
expect(output).to eql(file_content)
end

Then /^the checker should returns (.*) missing translations:$/ do |int, translations|
step %{the output should contain "✖ Missing translations found (#{int})"}
translations.raw.each do |tr|
Expand All @@ -81,3 +87,7 @@
When /^I run checker$/ do
run("localer check ../../spec/dummy_app")
end

When /^I run checker with json$/ do
run("localer check ../../spec/dummy_app --json output.json")
end