diff --git a/CHANGES.md b/CHANGES.md index 1ac58444..c37f42dd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## 0.8.1 + +* The default config file now excludes `app/assets/images` and app/assets/fonts`. Add `*.otf` to ignored extensions. +* If an error message occurs when scanning, the error message now includes the filename [#141](https://github.com/glebm/i18n-tasks/issues/141). + ## 0.8.0 * Parse command line arguments with `optparse`. Remove dependency on Slop. diff --git a/README.md b/README.md index 38afaf31..2e2ce74d 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,13 @@ Thus addressing the two main problems of [i18n gem][i18n-gem] design: i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (default in Rails). -Add it to the Gemfile: +Add i18n-tasks to the Gemfile: ```ruby -gem 'i18n-tasks', '~> 0.8.0' +gem 'i18n-tasks', '~> 0.8.1' ``` -Copy default [configuration file](#configuration) (optional): +Copy the default [configuration file](#configuration): ```console $ cp $(i18n-tasks gem-path)/templates/config/i18n-tasks.yml config/ diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 725418ac..7f0e0b41 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -4,86 +4,19 @@ # You can find the default config here: https://github.com/glebm/i18n-tasks/blob/master/templates/config/i18n-tasks.yml base_locale: en -## i18n-tasks detects locales automatically from the existing locale files -## uncomment to set locales explicitly -# locales: [en, es, fr] - -## i18n-tasks report locale, default: en, available: en, ru internal_locale: en -# Read and write locale data data: - ## by default, translation data are read from the file system, or you can provide a custom data adapter - # adapter: I18n::Tasks::Data::FileSystem - - # Locale files to read from read: - config/locales/%{locale}.yml - # - config/locales/*.%{locale}.yml - # - config/locales/**/*.%{locale}.yml - - # key => file routes, matched top to bottom write: - ## E.g., write devise and simple form keys to their respective files - # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml'] - # Catch-all - config/locales/%{locale}.yml - # `i18n-tasks normalize -p` will force move the keys according to these rules - - # YAML / JSON serializer options, passed to load / dump / parse / serialize yaml: write: ## do not wrap lines at 80 characters (override default) line_width: 96 - json: - write: - # pretty print JSON - indent: ' ' - space: ' ' - object_nl: "\n" - array_nl: "\n" # Find translate calls search: - ## Default scanner finds t() and I18n.t() calls - # scanner: I18n::Tasks::Scanners::PatternWithScopeScanner - - ## Paths to search in, passed to File.find paths: - lib/ - - ## Root for resolving relative keys (default) - # relative_roots: - # - app/views - - ## File.fnmatch patterns to exclude from search (default) - # exclude: ["*.jpg", "*.png", "*.gif", "*.svg", "*.ico", "*.eot", "*.ttf", "*.woff", "*.pdf"] - - ## Or, File.fnmatch patterns to include - # include: ["*.rb", "*.html.slim"] - -## 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" - -## Consider these keys not missing -# ignore_missing: -# - pagination.views.* - -## Consider these keys used -# ignore_unused: -# - 'simple_form.{yes,no}' -# - 'simple_form.{placeholders,hints,labels}.*' -# - 'simple_form.{error_notification,required}.:' - -## Exclude these keys from `i18n-tasks eq-base' report -# ignore_eq_base: -# all: -# - common.ok -# fr,es: -# - common.brand - -## Exclude these keys from all of the reports -# ignore: -# - kaminari.* diff --git a/lib/i18n/tasks/scanners/base_scanner.rb b/lib/i18n/tasks/scanners/base_scanner.rb index de0684db..1c2122b3 100644 --- a/lib/i18n/tasks/scanners/base_scanner.rb +++ b/lib/i18n/tasks/scanners/base_scanner.rb @@ -10,7 +10,7 @@ class BaseScanner attr_reader :config, :key_filter, :ignore_lines_res - ALWAYS_EXCLUDE = %w(*.jpg *.png *.gif *.svg *.ico *.eot *.ttf *.woff *.woff2 *.pdf + ALWAYS_EXCLUDE = %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json) def initialize(config = {}) diff --git a/lib/i18n/tasks/scanners/pattern_scanner.rb b/lib/i18n/tasks/scanners/pattern_scanner.rb index f09cb271..c32c60f3 100644 --- a/lib/i18n/tasks/scanners/pattern_scanner.rb +++ b/lib/i18n/tasks/scanners/pattern_scanner.rb @@ -22,6 +22,8 @@ def scan_file(path, opts = {}) keys << [key, data: location] end keys + rescue Exception => e + raise ::I18n::Tasks::CommandError.new("Error scanning #{path}: #{e.message}") end def default_pattern diff --git a/lib/i18n/tasks/version.rb b/lib/i18n/tasks/version.rb index 0c310029..9ec97e21 100644 --- a/lib/i18n/tasks/version.rb +++ b/lib/i18n/tasks/version.rb @@ -1,6 +1,6 @@ # coding: utf-8 module I18n module Tasks - VERSION = '0.8.0' + VERSION = '0.8.1' end end diff --git a/templates/config/i18n-tasks.yml b/templates/config/i18n-tasks.yml index 0cc2d7a3..137483b0 100644 --- a/templates/config/i18n-tasks.yml +++ b/templates/config/i18n-tasks.yml @@ -40,7 +40,6 @@ data: ## Pretty-print JSON: # json: - # # write: # indent: ' ' # space: ' ' @@ -61,8 +60,10 @@ search: # - 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 *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json) - # exclude: [] + ## %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.