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

Bug: Lint Translations ignoring app config and translations config #707

Open
Crisfole opened this issue Jun 15, 2023 · 2 comments
Open

Bug: Lint Translations ignoring app config and translations config #707

Crisfole opened this issue Jun 15, 2023 · 2 comments

Comments

@Crisfole
Copy link

Lint Translations is showing every single translation, even after builds work correctly and app is correctly configured.

Description

Every single locale defined by rails is being compared with my default locale, even though my translation file only lists 3 locales, and my available_locales are listed explicitly in my app config.

How to reproduce

  1. Install I18n-js gem
  2. Create a translation file.
  3. Create config/locales/en.yml config/locales/es.yml and config/locales/pl.yml files. In each create a single key: "frontend: { index: "Hello" }"
  4. Run i18n export notice that it works fine, exporting the default rails datetime/time content as well as your custom frontend: key. In the English (or your default locale in this app) translation add an extra key so that it's missing from spanish and polish.
  5. Run i18n lint:translations > missing_i18n.txt Be sure to redirect because otherwise you lose the history unless your terminal has a lot more lines than mine.
  6. Notice how it lists everything:

Translation File Contents

---
translations:
  - file: app/frontend/:locale.i18n.json
    patterns:
      - "{en,es,pl}.*"
      - "!*.faker"
      - "!*.administrate"
      - "!*.devise"
      - "!*.flash"
      - "!*.good_job"
      - "!*.helpers"
      - "!*.i18n_tasks"
      - "!*.stringex"
      - "!*.views"
      - "!*.activerecord"
      - "!*.errors"

What do you expect

I expect only en, es, and pl to be compared, and further that the ignored patterns from my translations also get ignored in the linter.

What happened instead

130166 line "missing_translations.txt" file with every single locale built into rails listed, and even the pattern keys listed.

Software:

  • Gem version: 4.2.3
  • Ruby version: ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-linux]

Full backtrace

N/A

@fnando
Copy link
Owner

fnando commented Jun 20, 2023

The lint configuration is unaware of patterns used by translations, as they're essentially two different plugins. The official way of doing what you want is by using the lint_translations.ignore config. It currently doesn't accept glob patterns, but given how you're planning to use it, I think it makes sense adding support for it. I'll work on that.

@falsefalse
Copy link

having patterns support in lint_translations.ignore would be useful, e.g. ignore all *.active_admin.* things

how would you approach the task? ruby is not my strongest suit, appreciate a pointer in the right direction 🙏

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

3 participants