Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New --config option doesn't appear to work. #409

Closed
geoffharcourt opened this issue Dec 22, 2021 · 14 comments
Closed

New --config option doesn't appear to work. #409

geoffharcourt opened this issue Dec 22, 2021 · 14 comments

Comments

@geoffharcourt
Copy link

The --config option to specify an alternate location for the configuration file doesn't appear to be accepted in either 0.9.35 (where it was added) or 0.9.36.

> i18n-tasks --config config/i18n-tasks.deployment.yml
i18n-tasks: invalid option: --config
@glebm
Copy link
Owner

glebm commented Dec 22, 2021

@krtschmr Can you please have a look?

@davidwessman
Copy link
Collaborator

@geoffharcourt Is it still applicable for the latest version?

bundle exec i18n-tasks --version    
1.0.5
bundle exec i18n-tasks --config what
i18n-tasks: Config file doesn't exist: what

@geoffharcourt
Copy link
Author

@davidwessman I'm not sure why, but in multiple environments we're still seeing this issue:

❯ bundle exec i18n-tasks --version
1.0.5
❯ bundle exec i18n-tasks --config config/i18n-tasks.deployment.yml
i18n-tasks: invalid option: --config

This happens if I run the gem (same version) from the system installation (not from bundler) we get the same behavior.

@davidwessman
Copy link
Collaborator

I cannot recreate this execpt for v0.9.34 when the option did not exist.

  • Could it be some gem cache?
  • Can you give more information about the environment?

@geoffharcourt
Copy link
Author

geoffharcourt commented May 16, 2022

Hi @davidwessman I'm still confused about what's going on. I checked and I don't have any of the pre-config option versions installed:

❯ gem list | grep i18n-tasks
i18n-tasks (1.0.10, 1.0.9)

I confirmed I'm using the version associated with my local Ruby installation (MacOS, Ruby 3.1.2):

❯ which i18n-tasks
/Users/geoff/.asdf/shims/i18n-tasks

And I'm still getting an error when trying to use the flag:

❯ i18n-tasks --config config/i18n-tasks.deployment.yml
i18n-tasks: invalid option: --config

@glebm
Copy link
Owner

glebm commented May 16, 2022

What does i18n-tasks --version say?

@geoffharcourt
Copy link
Author

Hi @glebm, sorry for not including that earlier:

❯ i18n-tasks --version
1.0.10

@davidwessman
Copy link
Collaborator

How does your i18n-tasks.yml look?

@geoffharcourt
Copy link
Author

@davidwessman I'd hope that only the one I'm referencing matters, but here's the one that's normally in place for us (config/i18n-tasks.yml, at the bottom is the one we're trying to use):

# 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: [en, es]
## 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
    - config/locales/%{locale}.json

  # 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:
      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/
    - react/
    - spec/

  ## 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
    - app/javascript/images
    - app/javascript/stylesheets
    # This file contains an intentionally badly encoded string
    - spec/events/student_responses/responder_spec.rb
    - spec/fixtures
    - spec/support/vendor

  ## 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: false

  ## 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:
  - '{devise,simple_form}.*'
  - 'active_admin.*'
  - 'activerecord.errors.models.*.*.must_be_today_or_in_the_future'
  - 'activerecord.errors.models.*.*.must_be_future'
  - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
  - 'formtastic.*'
  - 'here_be_dragons'
  - 'notfoundtestonly'
  - 'number.nth.ordinalized'
  - 'privacy_policy_body_es_html'

## Consider these keys used:
ignore_unused:
  - "*th"
  - "2nd"
  - "3rd"
  - '*_grade'
  - '*_grade_units_description'
  - '*_mailer.*.subject'
  - 'active_admin.resources.*'
  - 'activerecord.models.user'
  - 'assessment_series.*'
  - 'audio_speeds.*'
  - 'date.formats.*'
  - 'down'
  - 'educator_key_*'
  - 'ela_\(english_/_literature\)'
  - 'errors.messages.*'
  - 'esl_\(english_as_a_second_language\)'
  - 'formatastic.*'
  - 'full_common_core_standard_name.informational.*'
  - 'full_common_core_standard_name.literary.*'
  - 'genre_names.*'
  - 'grade_post_assessment'
  - 'grade_pre_assessment'
  - 'helpers.page_entries_info.*'
  - 'history_/_social_studies'
  - 'honors_/_ap'
  - 'language.*'
  - 'legacy_*_assessment'
  - 'legacy_*_assessment_data'
  - 'library_categories.*'
  - 'library_content.*'
  - 'library_content_pluralized.*'
  - 'literary_device_names.*'
  - 'mid_year_assessment'
  - 'models.*'
  - 'needs_grading'
  - 'number.nth.ordinalized'
  - 'other'
  - 'parts_of_speech.*'
  - 'please_enter_your_educator_key_*'
  - 'pre_assessment_performance.*'
  - 'promotion_names.*'
  - 'question_answer_formats.*'
  - 'reading_modality_headers.*'
  - 'sdp_charts.*'
  - 'simple_form.{error_notification,required}.:'
  - 'simple_form.{placeholders,hints,labels}.*'
  - 'simple_form.{yes,no}'
  - 'special_education'
  - 'standards_framework_labels.*'
  - 'stem_\(science_/_technology\)'
  - 'tab_headers.*'
  - 'theme_names.*'
  - 'time.formats.*'
  - 'up'
  - 'vocabulary_and_language'
  - '{activemodel,activerecord}.{attributes,errors}.*'
  - '{devise,kaminari,will_paginate}.*'

ignore_inconsistent_interpolations:
  - 'devise.mailer.email_changed.*'

## 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}']] %>

and here's the one I'm trying to use via the flag (config/i18n-tasks.deployment.yml):

---
# 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: [en, es]
## 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}.shaken.json

  # 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:
      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/javascript

  ## 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
    - app/javascript/images
    # This file contains an intentionally badly encoded string
    - spec/events/student_responses/responder_spec.rb
    - spec/fixtures
    - spec/support/vendor

  ## 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: false

  ## 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

## Do not consider these keys missing:
ignore_missing:
  - 'active_admin.*'
  - 'activerecord.errors.models.*.*.must_be_today_or_in_the_future'
  - 'activerecord.errors.models.*.*.must_be_future'
  - 'here_be_dragons'
  - 'privacy_policy_body_es_html'
  - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
  - 'formtastic.*'
  - '{devise,simple_form}.*'
  - 'notfoundtestonly'

## Consider these keys used:
ignore_unused:
  - '{activemodel,activerecord}.{attributes,errors}.*'
  - '{devise,kaminari,will_paginate}.*'
  - "*th"
  - "2nd"
  - "3rd"
  - '*_grade'
  - '*_grade_units_description'
  - '*_mailer.*.subject'
  - 'activerecord.models.user'
  - 'assessment_series.*'
  - 'audio_speeds.*'
  - 'date.formats.*'
  - 'down'
  - 'educator_key_*'
  - 'ela_\(english_/_literature\)'
  - 'errors.messages.*'
  - 'esl_\(english_as_a_second_language\)'
  - 'formatastic.*'
  - 'full_common_core_standard_name.informational.*'
  - 'full_common_core_standard_name.literary.*'
  - 'genre_names.*'
  - 'grade_post_assessment'
  - 'grade_pre_assessment'
  - 'helpers.page_entries_info.*'
  - 'history_/_social_studies'
  - 'honors_/_ap'
  - 'language.*'
  - 'legacy_*_assessment'
  - 'legacy_*_assessment_data'
  - 'library_categories.*'
  - 'library_content.*'
  - 'library_content_pluralized.*'
  - 'literary_device_names.*'
  - 'mid_year_assessment'
  - 'models.*'
  - 'other'
  - 'parts_of_speech.*'
  - 'please_enter_your_educator_key_*'
  - 'pre_assessment_performance.*'
  - 'question_answer_formats.*'
  - 'reading_modality_headers.*'
  - 'sdp_charts.*'
  - 'simple_form.{error_notification,required}.:'
  - 'simple_form.{placeholders,hints,labels}.*'
  - 'simple_form.{yes,no}'
  - 'special_education'
  - 'standards_framework_labels.*'
  - 'stem_\(science_/_technology\)'
  - 'tab_headers.*'
  - 'theme_names.*'
  - 'time.formats.*'
  - 'up'
  - 'vocabulary_and_language'

ignore_inconsistent_interpolations:
  - 'devise.mailer.email_changed.*'

@shev-vadim-net
Copy link
Contributor

I have the same issue. When a config file doesn't exist it shows correct error message

bundle exec i18n-tasks --config what
i18n-tasks: Config file doesn't exist: what

But when I use the real file path it shows

i18n-tasks: invalid option: --config

I was able to make it work with a simple change, see #455.

@davidwessman
Copy link
Collaborator

Ah, I only tested with non-existing files... Good find!

@davidwessman
Copy link
Collaborator

@glebm Closed by #455

@geoffharcourt
Copy link
Author

Thanks everyone for the help and the fix!

@krtschmr
Copy link
Contributor

@glebm yeah, sorry, i was "AFK" :-)

bundle exec i18n-tasks --config config/i18n-js-tasks.yml normalize this now works for me aswell.

thanks everybody for fixing my oversight.

💪🏿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants