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

Add missing key with nil value #170

Closed
pioz opened this issue Sep 16, 2015 · 2 comments
Closed

Add missing key with nil value #170

pioz opened this issue Sep 16, 2015 · 2 comments

Comments

@pioz
Copy link

pioz commented Sep 16, 2015

Hi, is possible add missing keys with nil value? Like

i18n-tasks add-missing -v nil it
@glebm
Copy link
Owner

glebm commented Sep 16, 2015

It is not possible with the command line currently, but you can define a custom task:

# config/i18n-tasks.yml
<%
  module AddMissingNil
    include ::I18n::Tasks::Command::Collection
    cmd :add_missing_nil,
            desc: 'Add missing keys with nil values',
            pos:  '[locale ...]',
            args: [:locales]
    def add_missing_nil(opt = {})
      add_missing opt.merge(value: nil)
    end
  end
  I18n::Tasks::Commands.send :include, AddMissingNil
%>

Then invoke it:

$ i18n-tasks add-missing-nil

@pioz pioz closed this as completed Sep 16, 2015
@pioz
Copy link
Author

pioz commented Sep 16, 2015

Great, it works!

glebm added a commit that referenced this issue Mar 6, 2016
By passing `--nil-value` to `add-missing`.
glebm added a commit that referenced this issue Mar 6, 2016
By passing `--nil-value` to `add-missing`.
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