i18n-tasks: "was a leaf, now has children (value <- scope conflict)" error

In two of my views, I have keys that go one level deeper than “necessary”. I have these for organizational purposes. i18n-tasks gives me this warning because of the keys. It would be great to have the ability to turn these warnings off, because I don’t consider this an issue.

# app/views/path/to/view

%p= t('.title')
%p= t('.extra.first') # this throws the warning
%p= t('.extra.second')
path:
  to:
    view:
      title: I am a webpage
      extra: 
        first: 1
        second: 2

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 20 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @jfly,

Thanks for reaching out. I can see that there is an issue with ignore not being applied to the keys in source, and I would consider merging a PR that fixes this. Or alternatively a PR that silences the warning for keys that are discovered in source (the “used_tree”).

However, in your case, instead of ignoring it I suggest a refactoring that avoids the problem altogether.

Instead of fetching the translations many times, you can do:

answers = t('faq.answers')
answers_in_en = t('faq.answers', locale: 'en')
answers_with_fallback = en_answers.deep_merge(answers)

This is less verbose and likely faster than calling t for every answer, and avoids dynamic t calls.

While not always true, most of the cases I’ve seen where this warning comes up are either: a case of a user error (as in incompatible data for different languages), or the user calling t excessively (as in your case).

Refs https://github.com/thewca/worldcubeassociation.org/pull/1293 https://github.com/thewca/worldcubeassociation.org/issues/1176