Closed frodrigo closed 7 years ago
This happens because i18n-tasks doesn't have its messages translated to French.
Please make sure the internal_locale
is set to en
in the config (or contribute a French translation: https://github.com/glebm/i18n-tasks/tree/master/config/locales).
Can you post the new stack trace and the output of i18n-tasks config
?
NoMethodError: undefined method `sample' for "translation missing: fr.i18n_tasks.cmd.encourage":String
/home/fred/.gem/gems/i18n-tasks-0.9.8/lib/i18n/tasks/reports/terminal.rb:160:in `print_success'
/home/fred/.gem/gems/i18n-tasks-0.9.8/lib/i18n/tasks/reports/terminal.rb:55:in `unused_keys'
/home/fred/.gem/gems/i18n-tasks-0.9.8/lib/i18n/tasks/command/options/data.rb:83:in `print_forest'
/home/fred/.gem/gems/i18n-tasks-0.9.8/lib/i18n/tasks/command/commands/usages.rb:30:in `unused'
/home/fred/.gem/gems/i18n-tasks-0.9.8/lib/i18n/tasks/command/commands/health.rb:20:in `health'
/home/fred/.gem/gems/i18n-tasks-0.9.8/lib/i18n/tasks/command/commander.rb:25:in `run'
/home/fred/.gem/gems/i18n-tasks-0.9.8/lib/i18n/tasks/cli.rb:41:in `run'
/home/fred/secret_project/code/secret_project/lib/tasks/test_enhance.rake:23:in `block in <top (required)>'
/home/fred/secret_project/code/secret_project/lib/tasks/test_enhance.rake:29:in `block in <top (required)>'
/home/fred/.gem/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/home/fred/.gem/ruby/2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
/home/fred/.gem/ruby/2.3.0/bin/bundle:23:in `load'
/home/fred/.gem/ruby/2.3.0/bin/bundle:23:in `<main>'
Tasks: TOP => i18n_health
i18n-tasks config
here?i18n-tasks missing
work if you call it directly?I'm run i18n-tasks missing
from tests via rake. For testing purpose my test are done with locale fr.
begin
if Gem::Specification.find_by_name('i18n-tasks')
require 'i18n/tasks/cli'
task :i18n_health do
I18n::Tasks::CLI.new.run(['health'])
I18n.locale = :fr
end
Rake::Task['test'].enhance do
if !ENV.key?('I18N') || ENV['I18N'] != 'false'
Rake::Task[:i18n_health].invoke
end
end
end
rescue Gem::LoadError
end
$ bundle exec i18n-tasks config
internal_locale: en
base_locale: en
locales:
- en
- fr
data:
adapter: I18n::Tasks::Data::FileSystem
read:
- config/locales/%{locale}.yml
write:
- config/locales/%{locale}.yml
yaml:
write:
line_width: -1
search:
paths:
- app/
relative_roots:
- app/controllers
- app/helpers
- app/mailers
- app/presenters
- app/views
scanners:
- - "::I18n::Tasks::Scanners::RubyAstScanner"
- only:
- "*.rb"
- - "::I18n::Tasks::Scanners::PatternWithScopeScanner"
- exclude:
- "*.rb"
ignore_lines:
opal: "^\\s*#(?!\\si18n-tasks-use)"
haml: "^\\s*-\\s*#(?!\\si18n-tasks-use)"
slim: "^\\s*(?:-#|/)(?!\\si18n-tasks-use)"
coffee: "^\\s*#(?!\\si18n-tasks-use)"
erb: "^\\s*<%\\s*#(?!\\si18n-tasks-use)"
strict: true
exclude:
- app/assets/images
- app/assets/fonts
ignore_missing:
- "{devise,leaflet_draw}.*"
ignore_unused:
- "*"
$ bundle exec i18n-tasks missing
works fine
The run
method currently doesn't set the locale, it is set in the start
method instead.
I'll move it to run
, but in the meantime you can either use start
(if you don't mind the command exiting on failure) or do this instead:
task :i18n_health do
I18n.with_locale 'en' do
I18n::Tasks::CLI.new.run(['health'])
end
end
This line is unnecessary:
I18n.locale = :fr
Ok, it works for me like this.
I run i18n_tasks in a locale without provided translation (fr). But it's fails on a:
I unsuccessfully locate where come from the sample method.