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

i18n-tasks unused is displaying a lot of *used* items #187

Closed
lucascaton opened this issue Feb 4, 2016 · 9 comments
Closed

i18n-tasks unused is displaying a lot of *used* items #187

lucascaton opened this issue Feb 4, 2016 · 9 comments

Comments

@lucascaton
Copy link

$ i18n-tasks unused

Unused keys (270) | i18n-tasks v0.9.3
+--------+--------------------------+----------+
| Locale | Key                      | Value    |
+--------+--------------------------+----------+
|   en   | accounts.transfer.submit | Transfer |
etc...
glebm added a commit that referenced this issue Feb 5, 2016
@glebm
Copy link
Owner

glebm commented Feb 5, 2016

@lucascaton Could you please try master? Thanks

@lucascaton
Copy link
Author

@glebm got the same result.

# Gemfile
gem 'i18n-tasks', require: false, github: 'glebm/i18n-tasks'
# Gemfile.lock
GIT
  remote: git://github.com/glebm/i18n-tasks.git
  revision: 3d7e71f21b37dca9eda95fd7fcc16e4ace152ce6

@lucascaton
Copy link
Author

config/i18n-tasks.yml:

base_locale: en

data:
  read:
    - config/locales/**/%{locale}.yml
    - config/locales/**/*.%{locale}.yml

# Ignoring the following keys because they are defined by 'rails-i18n' gem
ignore_missing:
- 'date.formats.*'
- 'number.currency.format.*'

search:
  exclude:
    - app/assets/images
    - app/assets/fonts

@glebm
Copy link
Owner

glebm commented Feb 6, 2016

I can't reproduce this at all. What version of ruby and activesupport are used? Does i18n-tasks find return anything?

@lucascaton lucascaton changed the title i18n-tasks unused is displaying everything i18n-tasks unused is displaying a lot of *used* items Feb 7, 2016
@lucascaton
Copy link
Author

Hi @glebm,

I just realised that it's not everything, I'll pick some examples and add here.

Also, i18n-tasks find seems to be working:

$ i18n-tasks find
138 keys (183 usages) | i18n-tasks v0.9.3
# ....

@lucascaton
Copy link
Author

Some examples:

1)

$ i18n-tasks unused
+--------+-----------------------------+-------+
| Locale | Key                         | Value |
+--------+-----------------------------+-------+
| ...                                          |
| en     | time.formats.month_and_year | %B %Y |
| ...                                          |
+--------+-----------------------------+-------+

It's used here:

# Controller
@date = l @month, format: :month_and_year

2)

$ i18n-tasks unused
+--------+----------------------------+----------+
| Locale | Key                        | Value    |
+--------+----------------------------+----------+
| ...                                            |
| en     | settings.users.index.title | Settings |
| ...                                            |
+--------+----------------------------+----------+

It's used here:

# Haml view
= title
# Helper
def title
  t("#{controller_path.gsub(%r{/}, '.')}.#{action_name}.title")
end

@glebm
Copy link
Owner

glebm commented Feb 8, 2016

  1. Since i18n-tasks 0.9.0, strict matching is enabled by default, so dynamic keys such as the title example above are not matched. If you enable the non-strict mode, either by passing --no-strict to the task or setting strict: false in the search config, all the :.:.title keys will be considered used.

@glebm
Copy link
Owner

glebm commented Feb 8, 2016

  1. i18n-tasks doesn't scan l calls, but you can add a magic comment there to specify the key in use:
# i18n-tasks-use t('time.formats.month_and_year')
@date = l @month, format: :month_and_year

@lucascaton
Copy link
Author

@glebm awesome, thanks again!

bartimaeus added a commit to bartimaeus/i18n-tasks that referenced this issue Apr 26, 2016
* upstream/master: (28 commits)
  Fix translation of plural HTML keys glebm#193
  Default config: exclude app/assets/videos glebm#194
  fix template config
  Bump to 0.9.5
  Pattern mapper documentation glebm#191
  Pattern mapper implementation glebm#191
  Add missing keys with `nil` value glebm#170
  Avoid changing the locale after running i18n-tasks
  changelog: 187 still not fixed
  Bump to 0.9.4
  Reference resolution reporting
  Document used_keys include_raw_references param
  Remove redundant filtering from unused_keys
  Improve reporting for unused keys
  Possible fix to glebm#187
  Improve reporting for missing ref keys
  minor refactors
  Bump to 0.9.3
  Readme: reference keys
  Copy reference keys as is in add/translate-missing
  ...
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

2 participants