i18n-tasks
i18n-tasks copied to clipboard
defining `one`, `other` is detected as missing keys.
with the latest i18n-tasks gem, defining those keys
ja:
foo:
one: いち
en:
foo:
one: One
then others
are detected as missing, even when it's not actually required by application.
% bundle exec i18n-tasks missing
#StandWithUkraine
Missing translations (2) | i18n-tasks v1.0.12
+--------+-----+----------------------------------+
| Locale | Key | Value in other locales or source |
+--------+-----+----------------------------------+
| en | foo | other |
| ja | foo | other |
+--------+-----+----------------------------------+
probably fixing https://github.com/glebm/i18n-tasks/issues/464 caused another bug.
Yeah, there is no longer any special handling for these keys (because the previous heuristic missed some legitimate non-plural keys).
One option to improve this in i18n-tasks
would be to determine whether a key is plural by looking at how it is used.
For now, you can work around this by adding such keys to ignore_missing
.
I am assuming you have foo.other
defined in en
but not ja
, right?
no, I'm not defining foo.other
anywhere.
Interestingly, with
foo:
one: One
two: Two
other
is reported as missing.
foo:
one: One
two: Two
three: Three
no missing keys.
How're you using this key (the t(...)
call)?
actually, we're overwriting datetime.distance_in_words.x_days.one
and rails itself uses it via time_ago_in_words
helper method.
plus, we have specs for i18n strings. our missing key spec (the first one) is failing after update i18n-tasks v1.0.11 to v1.0.12.
RSpec.describe I18n do
let(:i18n) { I18n::Tasks::BaseTask.new }
it do
expect(i18n.missing_keys).to be_empty
end
it do
expect(i18n.unused_keys).to be_empty
end
it do
expect(i18n.inconsistent_interpolations).to be_empty
end
end
this is the most simple rails app including single i18n string welcome_message.one
.
https://github.com/nov/i18n_demo
you'll see the missing other
by running bundle exec i18n-tasks missing
.
I'm seeing something similar when only other
is defined.
en:
some_key:
other: this is flagged as unused
some_key.other
is flagged as unused and some_key.one
as missing.
This bug is still in effect. I added a new key with
shared:
addresses:
guidance:
one: "Do this"
two: "not that"
To an existing locale file and got flagged as
Missing translations (1) | i18n-tasks v1.0.14
+--------+---------------------------+----------------------------------+
| Locale | Key | Value in other locales or source |
+--------+---------------------------+----------------------------------+
| en | shared.addresses.guidance | other |
+--------+---------------------------+----------------------------------+
Renaming the new keys to first and second
shared:
addresses:
guidance:
first: "Do this"
second: "not that"
and the warning no longer appears