i18n-tasks
i18n-tasks copied to clipboard
Many false positives in unused
I have quiet fresh Rails project and I get many false positives when I run bundle exec i18n-tasks unused
e.g. I have <h1><%= t('welcome message h1') %></h1>
in my application.html.erb and I get this key as unused for all languages.
It's the same for many other translations I use in my views.
I use ruby-2.7.2, rails-6.1.0, i18n-tasks-0.9.33
Hi !
I use version 0.9.34 but can tell it was already present on previous versions.
I got this yaml:
fr:
activerecord:
models:
genus:
one: Genre
other: Genres
and a file with:
# auto-generated models an attributes for i18n
# i18n-tasks-use t('activerecord.models.genus')
Which works as expected.
But once I target one
or other
key, the whole fr.activerecord.model.genus
gets flagged as unused:
<%= t('activerecord.models.genus.one') %>
+--------+--------------------------------------------+-------------------------------------+
| Locale | Key | Value |
+--------+--------------------------------------------+-------------------------------------+
| en | activerecord.models.genus | {"one"=>"Genus", "other"=>"Genera"} |
| fr | activerecord.models.genus | {"one"=>"Genre", "other"=>"Genres"} |
@nurbs999 Can you please explain how your translation files looks to work with a key like welcome message h1
?
@mtancoigne Hello! I tried to recreate this problem, and it seems to be a limitation with pluralization - if you have a pluralized translation you will have to use one of:
-
t("activerecord.models.genus", count: nbr)
-
t("activerecord.models.genus.one")
in combination withi18n-tasks use t("activerecord.models.genus")
.
I don't have the project running anymore. I will try to reproduce it on my current setup, which is ruby-3.0.2, rails-6.1.4
@davidwessman Thanks for your reply, that's what I do currently. I'll stick with this : it's not really an issue unless I want the model name in JS scripts (as the i18n lib I use don't have the same format for plural forms).