Adds i18n-tasks

This commit is contained in:
kikito
2015-08-06 18:31:26 +02:00
parent 72c33330cf
commit b1acbeb39d
4 changed files with 141 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ group :development, :test do
gem 'launchy' gem 'launchy'
gem 'quiet_assets' gem 'quiet_assets'
gem 'letter_opener_web', '~> 1.2.0' gem 'letter_opener_web', '~> 1.2.0'
gem 'i18n-tasks'
end end
group :test do group :test do

View File

@@ -94,6 +94,10 @@ GEM
docile (1.1.5) docile (1.1.5)
domain_name (0.5.24) domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
easy_translate (0.5.0)
json
thread
thread_safe
erubis (2.7.0) erubis (2.7.0)
execjs (2.5.2) execjs (2.5.2)
factory_girl (4.5.0) factory_girl (4.5.0)
@@ -106,9 +110,18 @@ GEM
sass (>= 3.3.0, < 3.5) sass (>= 3.3.0, < 3.5)
globalid (0.3.5) globalid (0.3.5)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
highline (1.7.3)
http-cookie (1.0.2) http-cookie (1.0.2)
domain_name (~> 0.5) domain_name (~> 0.5)
i18n (0.7.0) i18n (0.7.0)
i18n-tasks (0.8.6)
activesupport
easy_translate (>= 0.5.0)
erubis
highline
i18n
term-ansicolor
terminal-table (>= 1.5.1)
jbuilder (2.3.1) jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5) activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2) multi_json (~> 1.2)
@@ -221,7 +234,9 @@ GEM
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
term-ansicolor (1.3.2) term-ansicolor (1.3.2)
tins (~> 1.0) tins (~> 1.0)
terminal-table (1.5.2)
thor (0.19.1) thor (0.19.1)
thread (0.2.2)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (1.4.1)
tins (1.5.4) tins (1.5.4)
@@ -264,6 +279,7 @@ DEPENDENCIES
devise devise
factory_girl_rails factory_girl_rails
foundation-rails foundation-rails
i18n-tasks
jbuilder (~> 2.0) jbuilder (~> 2.0)
jquery-rails jquery-rails
launchy launchy
@@ -283,4 +299,4 @@ DEPENDENCIES
web-console (~> 2.0) web-console (~> 2.0)
BUNDLED WITH BUNDLED WITH
1.10.5 1.10.6

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

@@ -0,0 +1,106 @@
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
# The "main" locale.
base_locale: en
## 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 (replace %#= with %=):
# - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
- config/locales/%{locale}.yml
- config/locales/devise_views.%{locale}.yml
- config/locales/responders.%{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/controllers
# - app/helpers
# - app/mailers
# - app/presenters
# - app/views
## 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/i18n_spec.rb Normal file
View File

@@ -0,0 +1,17 @@
require 'i18n/tasks'
RSpec.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