From 03ff8d1733ccc6acb1d7fbf94170404a27bbe9c2 Mon Sep 17 00:00:00 2001 From: "Michael J. Giarlo" Date: Fri, 16 Jun 2017 14:07:43 -0700 Subject: [PATCH] Add i18n-tasks gem and configuration for easier management of locales --- Gemfile | 1 + Gemfile.lock | 20 +++++++ config/i18n-tasks.yml | 121 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 config/i18n-tasks.yml diff --git a/Gemfile b/Gemfile index 0d1e077bd..e5224b9d4 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,7 @@ group :development, :test do gem 'byebug' gem 'i18n-debug', require: false + gem 'i18n-tasks' gem 'rspec' gem 'rspec-rails', '>= 3.6.0' diff --git a/Gemfile.lock b/Gemfile.lock index b533418d5..5ebd49a80 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -271,12 +271,17 @@ GEM dry-equalizer (~> 0.2) dry-logic (~> 0.4, >= 0.4.0) dry-types (~> 0.9, >= 0.9.0) + easy_translate (0.5.0) + json + thread + thread_safe ebnf (1.1.0) rdf (~> 2.0) sxp (~> 1.0) equivalent-xml (0.6.0) nokogiri (>= 1.4.3) erubi (1.6.0) + erubis (2.7.0) execjs (2.7.0) factory_girl (4.8.0) activesupport (>= 3.0.0) @@ -323,6 +328,7 @@ GEM hamster (3.0.0) concurrent-ruby (~> 1.0) hashdiff (0.3.4) + highline (1.7.8) hiredis (0.6.1) honeybadger (3.1.2) htmlentities (4.3.4) @@ -374,6 +380,16 @@ GEM i18n (0.8.4) i18n-debug (1.1.0) i18n (< 1) + i18n-tasks (0.9.15) + activesupport (>= 4.0.2) + ast (>= 2.1.0) + easy_translate (>= 0.5.0) + erubis + highline (>= 1.7.3) + i18n + parser (>= 2.2.3.0) + rainbow (~> 2.2) + terminal-table (>= 1.5.1) ice_nine (0.11.2) iiif-presentation (0.2.0) activesupport (>= 3.2.18) @@ -800,7 +816,10 @@ GEM temple (0.8.0) term-ansicolor (1.6.0) tins (~> 1.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) thor (0.19.4) + thread (0.2.2) thread_safe (0.3.6) tilt (2.0.7) tins (1.14.0) @@ -866,6 +885,7 @@ DEPENDENCIES honeybadger (~> 3.0) hyrax! i18n-debug + i18n-tasks iiif_manifest (~> 0.2.0) is_it_working jbuilder (~> 2.5) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml new file mode 100644 index 000000000..6d06e00db --- /dev/null +++ b/config/i18n-tasks.yml @@ -0,0 +1,121 @@ +# 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" + + # 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: + - ['{blacklight, devise, devise_invitable, generic_work, hyrax, image, 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: conservative_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 + - app/assets/videos + + ## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`: + ## If specified, this settings takes priority over `exclude`, but `exclude` still applies. + # only: ["*.rb", "*.html.slim"] + + ## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`. + # strict: true + + ## Multiple scanners can be used. Their results are merged. + ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well. + ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example + +## 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.* + +## Sometimes, it isn't possible for i18n-tasks to match the key correctly, +## e.g. in case of a relative key defined in a helper method. +## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.: +# +# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper', +# only: %w(*.html.haml *.html.slim), +# patterns: [['= title\b', '.page_title']] %> +# +# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.: +# +# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper', +# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>