Introduce the i18n-tasks gem

This commit is contained in:
Petko Bordjukov 2015-04-20 15:56:41 +03:00
parent 167976eedc
commit 4e1e47192d
4 changed files with 139 additions and 0 deletions

View File

@ -65,4 +65,5 @@ group :development, :test do
gem 'faker'
gem 'capybara'
gem 'simplecov'
gem 'i18n-tasks'
end

View File

@ -107,6 +107,10 @@ GEM
devise-i18n (0.12.0)
diff-lcs (1.2.5)
docile (1.1.5)
easy_translate (0.5.0)
json
thread
thread_safe
erubis (2.7.0)
execjs (2.5.0)
factory_girl (4.5.0)
@ -139,10 +143,19 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
highline (1.7.2)
hike (1.2.3)
hirb (0.7.3)
hitimes (1.2.2)
i18n (0.7.0)
i18n-tasks (0.8.2)
activesupport
easy_translate (>= 0.5.0)
erubis
highline
i18n
term-ansicolor
terminal-table
i18n_data (0.6.3)
jquery-datatables-rails (3.2.0)
actionpack (>= 3.1)
@ -306,14 +319,19 @@ GEM
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
temple (0.7.5)
term-ansicolor (1.3.0)
tins (~> 1.0)
terminal-table (1.4.5)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread (0.2.0)
thread_safe (0.3.5)
tilt (1.4.1)
timers (4.0.1)
hitimes
tins (1.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.1)
@ -347,6 +365,7 @@ DEPENDENCIES
globalize
guard-rspec
hirb
i18n-tasks
jquery-datatables-rails
jquery-rails
morrisjs-rails

102
config/i18n-tasks.yml Normal file
View File

@ -0,0 +1,102 @@
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
# The "main" locale.
base_locale: bg
## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
# locales: [es, fr]
## Reporting locale, default: en. Available: en, ru.
# internal_locale: en
# Read and write translations.
data:
## Translations are read from the file system. Supported format: YAML, JSON.
## Provide a custom adapter:
# adapter: I18n::Tasks::Data::FileSystem
# Locale files or `File.find` patterns where translations are read from:
read:
## Default:
# - config/locales/%{locale}.yml
## More files:
# - config/locales/**/*.%{locale}.yml
## Another gem:
# - "<%= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
# `i18n-tasks normalize -p` will force move the keys according to these rules
write:
## For example, write devise and simple form keys to their respective files:
# - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
## Catch-all default:
# - config/locales/%{locale}.yml
## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
# router: convervative_router
yaml:
write:
# do not wrap lines at 80 characters
line_width: -1
## Pretty-print JSON:
# json:
# write:
# indent: ' '
# space: ' '
# object_nl: "\n"
# array_nl: "\n"
# Find translate calls
search:
## Paths or `File.find` patterns to search in:
# paths:
# - app/
## Root directories for relative keys resolution.
# relative_roots:
# - app/views
# - app/controllers
# - app/helpers
# - app/presenters
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
exclude:
- app/assets/images
- app/assets/fonts
## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
# include: ["*.rb", "*.html.slim"]
## Default scanner finds t() and I18n.t() calls.
# scanner: I18n::Tasks::Scanners::PatternWithScopeScanner
## Google Translate
# translation:
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
# api_key: "AbC-dEf5"
## Do not consider these keys missing:
# ignore_missing:
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
# - '{devise,simple_form}.*'
## Consider these keys used:
# ignore_unused:
# - 'activerecord.attributes.*'
# - '{devise,kaminari,will_paginate}.*'
# - 'simple_form.{yes,no}'
# - 'simple_form.{placeholders,hints,labels}.*'
# - 'simple_form.{error_notification,required}.:'
## Exclude these keys from the `i18n-tasks eq-base' report:
# ignore_eq_base:
# all:
# - common.ok
# fr,es:
# - common.brand
## Ignore these keys completely:
# ignore:
# - kaminari.*

17
spec/models/i18n_spec.rb Normal file
View File

@ -0,0 +1,17 @@
require 'i18n/tasks'
describe 'I18n' do
let(:i18n) { I18n::Tasks::BaseTask.new }
let(:missing_keys) { i18n.missing_keys }
let(:unused_keys) { i18n.unused_keys }
it 'does not have missing keys' do
expect(missing_keys).to be_empty,
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
end
it 'does not have unused keys' do
expect(unused_keys).to be_empty,
"#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
end
end