From 98e2122c89e7ab67d1fc8965aa7cfa52fc36243b Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Tue, 8 Dec 2020 10:35:41 -0500 Subject: [PATCH] release 7.5.1 - add missing translations * add test to catch missing translations in the future using i18n-tasks gem --- CHANGELOG.md | 6 ++ config/i18n-tasks.yml | 133 ++++++++++++++++++++++++++++++++ config/locales/qa_server.en.yml | 14 ++++ lib/qa_server/version.rb | 2 +- qa_server.gemspec | 1 + spec/i18n_spec.rb | 36 +++++++++ 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 config/i18n-tasks.yml create mode 100644 spec/i18n_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index ab7828e..33ac35f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 7.5.1 (2020-12-08) + +* define missing i18n translations +* add i18n-tasks gem for managing translations +* add spec test to check for missing translations + ### 7.5.0 (2020-12-07) * UI improvements of check_status page diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml new file mode 100644 index 0000000..3a28757 --- /dev/null +++ b/config/i18n-tasks.yml @@ -0,0 +1,133 @@ +# 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 + + # 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 + + # External locale data (e.g. gems). + # This data is not considered unused and is never written to. + external: + ## Example (replace %#= with %=): + # - "<%#= %x[bundle show vagrant].chomp %>/templates/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 + +## Translation Services +# translation: +# # Google Translate +# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate +# google_translate_api_key: "AbC-dEf5" +# # DeepL Pro Translate +# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro +# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A" + +## 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 + +## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report: +# ignore_inconsistent_interpolations: +# - 'activerecord.attributes.*' + +## 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}']] %> diff --git a/config/locales/qa_server.en.yml b/config/locales/qa_server.en.yml index 472f8a3..83dfd58 100644 --- a/config/locales/qa_server.en.yml +++ b/config/locales/qa_server.en.yml @@ -1,6 +1,12 @@ --- en: qa_server: + application_name: "Replace with your application's name" + application_version: "Replace with your application's version" + footer: + attribution_html: This service is supported by work on Linked Data for Libraries - Labs and
Linked Data for Production funded by Andrew W. Mellon Foundation,
and by work on Questioning Authority in Samvera, an open source community. + copyright_html: Copyright © 2018-2020 Your Institution Licensed under the Apache License, Version 2.0 + service_html: A service of Your Institution Name. menu: home: Home usage: Usage @@ -22,11 +28,15 @@ en: show_all: ALL Authorities (SLOW) connections: Check Connection Status only accuracy: Check Accuracy only + comparison: Compare Accuracy all_checks: Run all checks wait_message: "Please wait while the status is verified. This will be slow if you selected ALL Authorities." connection_checks: Connection Checks accuracy_checks: Accuracy Checks for Search Results + comparison_checks: Comparison of Accuracy Checks status_table: + before: Before + after: After action: Action actual_position: Actual Position authority: Authority @@ -98,6 +108,10 @@ en: now: NOW today: TODAY datatable_desc: 'Performance tabulated data' + datatable_all_desc: 'All Data' + datatable_day_desc: 'Day' + datatable_month_desc: 'Month' + datatable_year_desc: 'Year' datarange: 'From %{from} to %{to}' authority: Authority average_times: Average (ms) diff --git a/lib/qa_server/version.rb b/lib/qa_server/version.rb index 3d9a1eb..5203f7b 100644 --- a/lib/qa_server/version.rb +++ b/lib/qa_server/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module QaServer - VERSION = '7.5.0' + VERSION = '7.5.1' end diff --git a/qa_server.gemspec b/qa_server.gemspec index 0bb7820..b4dfa6c 100644 --- a/qa_server.gemspec +++ b/qa_server.gemspec @@ -41,6 +41,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'deprecation' spec.add_development_dependency 'engine_cart', '~> 2.0' spec.add_development_dependency "factory_bot", '~> 4.4' + spec.add_development_dependency 'i18n-tasks' spec.add_development_dependency 'simplecov' spec.add_development_dependency 'sqlite3' spec.add_development_dependency 'rails-controller-testing', '~> 1' diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb new file mode 100644 index 0000000..ab82487 --- /dev/null +++ b/spec/i18n_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +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 } + let(:inconsistent_interpolations) { i18n.inconsistent_interpolations } + + 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 + pending 'need to explore unused keys further' + expect(unused_keys).to be_empty, + "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them" + end + + it 'files are normalized' do # rubocop:disable RSpec/ExampleLength + pending 'need to explore further normalization process' + non_normalized = i18n.non_normalized_paths + error_message = "The following files need to be normalized:\n" \ + "#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \ + "Please run `i18n-tasks normalize' to fix" + expect(non_normalized).to be_empty, error_message + end + + it 'does not have inconsistent interpolations' do + error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \ + "Run `i18n-tasks check-consistent-interpolations' to show them" + expect(inconsistent_interpolations).to be_empty, error_message + end +end