Skip to content

Commit

Permalink
Merge pull request #676 from DavidS/message-fixes
Browse files Browse the repository at this point in the history
(maint) Message and string fixes
  • Loading branch information
scotje authored Jul 2, 2019
2 parents 2a66f44 + b3080f6 commit 230d871
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 76 deletions.
4 changes: 2 additions & 2 deletions lib/pdk/analytics/client/google_analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initialize(opts)

def screen_view(screen, **kwargs)
custom_dimensions = walk_keys(kwargs) do |k|
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '#{k}'")
CUSTOM_DIMENSIONS[k] || raise(_("Unknown analytics key '%{key}'") % { key: k })
end

screen_view_params = {
Expand All @@ -54,7 +54,7 @@ def screen_view(screen, **kwargs)

def event(category, action, label: nil, value: nil, **kwargs)
custom_dimensions = walk_keys(kwargs) do |k|
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '#{k}'")
CUSTOM_DIMENSIONS[k] || raise(_("Unknown analytics key '%{key}'") % { key: k })
end

event_params = {
Expand Down
2 changes: 0 additions & 2 deletions lib/pdk/cli/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ module PDK::CLI
description _(<<-EOF
[experimental] For advanced users, pdk bundle runs arbitrary commands in the bundler environment that pdk manages.
Careless use of this command can lead to errors that pdk can't help recover from.
Note that for PowerShell the '--' needs to be escaped using a backtick: '`--' to avoid it being parsed by the shell.
EOF
)
skip_option_parsing
Expand Down
4 changes: 2 additions & 2 deletions lib/pdk/cli/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ def check_for_legacy_env_vars
if ENV['PUPPET_GEM_VERSION']
PDK.logger.warn_once _(
'PUPPET_GEM_VERSION is not supported by PDK. ' \
'Please use the --puppet-version option on your PDK command ' \
'Use the --puppet-version option on your PDK command ' \
'or set the PDK_PUPPET_VERSION environment variable instead',
)
@process.environment['PUPPET_GEM_VERSION'] = nil
end

%w[FACTER HIERA].each do |gem|
if ENV["#{gem}_GEM_VERSION"]
PDK.logger.warn_once _("#{gem}_GEM_VERSION is not supported by PDK.")
PDK.logger.warn_once _('%{varname} is not supported by PDK.') % { varname: "#{gem}_GEM_VERSION" }
@process.environment["#{gem}_GEM_VERSION"] = nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/cli/exec_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def parallel?
end

def register(&block)
raise PDK::CLI::FatalError, 'No block registered' unless block_given?
raise PDK::CLI::FatalError, _('No block registered') unless block_given?

@threads_or_procs << if parallel?
Thread.new do
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/cli/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def validate_puppet_version_opts(opts)
[puppet_ver_specs, pe_ver_specs].each do |offending|
next if offending.empty?

raise PDK::CLI::ExitWithError, _('You cannot specify a %{first} and %{second} at the same time') % {
raise PDK::CLI::ExitWithError, _('You cannot specify a %{first} and %{second} at the same time.') % {
first: pup_dev_spec,
second: offending.first,
}
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/config/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Validator
def self.boolean
{
proc: ->(value) { [true, false].include?(value) },
message: _('must be a boolean true or false'),
message: _('must be a boolean: true or false'),
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/config/value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initialize(name)
#
# @return [nil]
def validate(validator)
raise ArgumentError, _('validator must be a Hash') unless validator.is_a?(Hash)
raise ArgumentError, _('`validator` must be a Hash') unless validator.is_a?(Hash)
raise ArgumentError, _('the :proc key must contain a Proc') unless validator.key?(:proc) && validator[:proc].is_a?(Proc)
raise ArgumentError, _('the :message key must contain a String') unless validator.key?(:message) && validator[:message].is_a?(String)

Expand Down
24 changes: 17 additions & 7 deletions lib/pdk/generate/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,27 @@ def self.module_interview(metadata, opts = {})

interview.add_questions(questions)

action = File.file?('metadata.json') ? _('update') : _('create')
if File.file?('metadata.json')
puts _(
"\nWe need to update the metadata.json file for this module, so we\'re going to ask you %{count} " \
"questions.\n",
) % {
count: interview.num_questions,
}
else
puts _(
"\nWe need to create the metadata.json file for this module, so we\'re going to ask you %{count} " \
"questions.\n",
) % {
count: interview.num_questions,
}
end

puts _(
"\nWe need to %{action} the metadata.json file for this module, so we\'re going to ask you %{count} " \
"questions.\n" \
'If the question is not applicable to this module, accept the default option ' \
'shown after each question. You can modify any answers at any time by manually updating ' \
"the metadata.json file.\n\n",
) % {
count: interview.num_questions,
action: action,
}
)

answers = interview.run

Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/module/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def stage_path(path)
end
rescue ArgumentError => e
raise PDK::CLI::ExitWithError, _(
'%{message} Please rename the file or exclude it from the package ' \
'%{message} Rename the file or exclude it from the package ' \
'by adding it to the .pdkignore file in your module.',
) % { message: e.message }
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pdk/module/templatedir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ def checkout_template_ref(path, ref)

PDK.logger.error reset_result[:stdout]
PDK.logger.error reset_result[:stderr]
raise PDK::CLI::FatalError, _("Unable to set HEAD of git repository at '%{repo}' to ref:'%{ref}'.") % { repo: path, ref: ref }
raise PDK::CLI::FatalError, _("Unable to checkout '%{ref}' of git repository at '%{path}'.") % { ref: ref, path: path }
end
else
PDK.logger.warn _("Uncommitted changes found when attempting to set HEAD of git repository at '%{repo}' to ref '%{ref}'; skipping git reset.") % { repo: path, ref: ref }
PDK.logger.warn _("Uncommitted changes found when attempting to checkout '%{ref}' of git repository at '%{path}'; skipping git reset.") % { ref: ref, path: path }
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/pdk/util/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def self.work_tree?(path)
end

def self.work_dir_clean?(repo)
raise PDK::CLI::ExitWithError, _('Unable to locate git work dir "%{workdir}') % { workdir: repo } unless File.directory?(repo)
raise PDK::CLI::ExitWithError, _('Unable to locate git dir "%{gitdir}') % { gitdir: repo } unless File.directory?(File.join(repo, '.git'))
raise PDK::CLI::ExitWithError, _('Unable to locate git work dir "%{workdir}"') % { workdir: repo } unless File.directory?(repo)
raise PDK::CLI::ExitWithError, _('Unable to locate git dir "%{gitdir}"') % { gitdir: repo } unless File.directory?(File.join(repo, '.git'))

git('--work-tree', repo, '--git-dir', File.join(repo, '.git'), 'status', '--untracked-files=no', '--porcelain', repo)[:stdout].empty?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/util/puppet_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def fetch_puppet_dev

PDK.logger.error clone_result[:stdout]
PDK.logger.error clone_result[:stderr]
raise PDK::CLI::FatalError, _("Unable to clone git repository at '%{repo}'.") % { repo: DEFAULT_PUPPET_DEV_URL }
raise PDK::CLI::FatalError, _("Unable to clone git repository from '%{repo}'.") % { repo: DEFAULT_PUPPET_DEV_URL }
end

# Fetch Updates from remote repository
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/validate/tasks/name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Validate
class Tasks
class Name < BaseValidator
INVALID_TASK_MSG = _(
'Invalid task name. Task names must start with a lowercase letter' \
'Invalid task name. Task names must start with a lowercase letter ' \
'and can only contain lowercase letters, numbers, and underscores.',
)

Expand Down
70 changes: 37 additions & 33 deletions locales/pdk.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: puppet development kit v1.11.0-5-gd7565ab\n"
"Project-Id-Version: puppet development kit v1.11.1-1-g8953096\n"
"\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2019-07-01 15:57+1000\n"
"PO-Revision-Date: 2019-07-01 15:57+1000\n"
"POT-Creation-Date: 2019-07-01 12:09+0100\n"
"PO-Revision-Date: 2019-07-01 12:09+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
Expand All @@ -19,6 +19,10 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: ../lib/pdk/analytics/client/google_analytics.rb:42 ../lib/pdk/analytics/client/google_analytics.rb:57
msgid "Unknown analytics key '%{key}'"
msgstr ""

#: ../lib/pdk/answer_file.rb:59
msgid "Answer file can be updated only with a Hash"
msgstr ""
Expand Down Expand Up @@ -163,11 +167,9 @@ msgstr ""
msgid ""
"[experimental] For advanced users, pdk bundle runs arbitrary commands in the bundler environment that pdk manages.\n"
"Careless use of this command can lead to errors that pdk can't help recover from.\n"
"\n"
"Note that for PowerShell the '--' needs to be escaped using a backtick: '`--' to avoid it being parsed by the shell.\n"
msgstr ""

#: ../lib/pdk/cli/bundle.rb:17
#: ../lib/pdk/cli/bundle.rb:15
msgid "`pdk bundle` can only be run from inside a valid module directory."
msgstr ""

Expand Down Expand Up @@ -228,11 +230,11 @@ msgid "Expected execution context to be :system or :module but got '%{context}'.
msgstr ""

#: ../lib/pdk/cli/exec.rb:126
msgid "PUPPET_GEM_VERSION is not supported by PDK. Please use the --puppet-version option on your PDK command or set the PDK_PUPPET_VERSION environment variable instead"
msgid "PUPPET_GEM_VERSION is not supported by PDK. Use the --puppet-version option on your PDK command or set the PDK_PUPPET_VERSION environment variable instead"
msgstr ""

#: ../lib/pdk/cli/exec.rb:136
msgid "#{gem}_GEM_VERSION is not supported by PDK."
msgid "%{varname} is not supported by PDK."
msgstr ""

#: ../lib/pdk/cli/exec.rb:175
Expand Down Expand Up @@ -263,6 +265,10 @@ msgstr ""
msgid "Execution of '%{command}' complete (duration: %{duration_in_seconds}s; exit code: %{exit_code})"
msgstr ""

#: ../lib/pdk/cli/exec_group.rb:30
msgid "No block registered"
msgstr ""

#: ../lib/pdk/cli/module.rb:4
msgid "module [options]"
msgstr ""
Expand Down Expand Up @@ -519,11 +525,7 @@ msgstr ""
msgid "Using %{gem} %{version}"
msgstr ""

#: ../lib/pdk/cli/util.rb:167
msgid "You cannot specify a %{first} and %{second} at the same time"
msgstr ""

#: ../lib/pdk/cli/util.rb:179
#: ../lib/pdk/cli/util.rb:167 ../lib/pdk/cli/util.rb:179
msgid "You cannot specify a %{first} and %{second} at the same time."
msgstr ""

Expand Down Expand Up @@ -638,15 +640,15 @@ msgid "Unable to open %{file} for writing"
msgstr ""

#: ../lib/pdk/config/validator.rb:16
msgid "must be a boolean true or false"
msgid "must be a boolean: true or false"
msgstr ""

#: ../lib/pdk/config/validator.rb:26
msgid "must be a version 4 UUID"
msgstr ""

#: ../lib/pdk/config/value.rb:42
msgid "validator must be a Hash"
msgid "`validator` must be a Hash"
msgstr ""

#: ../lib/pdk/config/value.rb:43
Expand Down Expand Up @@ -795,35 +797,37 @@ msgstr ""
msgid "If there is a public issue tracker for this module, enter its URL here."
msgstr ""

#: ../lib/pdk/generate/module.rb:261
msgid "update"
#: ../lib/pdk/generate/module.rb:262
msgid ""
"\n"
"We need to update the metadata.json file for this module, so we\\'re going to ask you %{count} questions.\n"
msgstr ""

#: ../lib/pdk/generate/module.rb:261
msgid "create"
#: ../lib/pdk/generate/module.rb:269
msgid ""
"\n"
"We need to create the metadata.json file for this module, so we\\'re going to ask you %{count} questions.\n"
msgstr ""

#: ../lib/pdk/generate/module.rb:262
#: ../lib/pdk/generate/module.rb:277
msgid ""
"\n"
"We need to %{action} the metadata.json file for this module, so we\\'re going to ask you %{count} questions.\n"
"If the question is not applicable to this module, accept the default option shown after each question. You can modify any answers at any time by manually updating the metadata.json file.\n"
"\n"
msgstr ""

#: ../lib/pdk/generate/module.rb:276
#: ../lib/pdk/generate/module.rb:286
msgid "No answers given, interview cancelled."
msgstr ""

#: ../lib/pdk/generate/module.rb:300
#: ../lib/pdk/generate/module.rb:310
msgid "Metadata will be generated based on this information, continue?"
msgstr ""

#: ../lib/pdk/generate/module.rb:302
#: ../lib/pdk/generate/module.rb:312
msgid "Interview cancelled; exiting."
msgstr ""

#: ../lib/pdk/generate/module.rb:306
#: ../lib/pdk/generate/module.rb:316
msgid "Process cancelled; exiting."
msgstr ""

Expand Down Expand Up @@ -904,7 +908,7 @@ msgid "A task named '%{name}' already exists in this module; defined in %{file}"
msgstr ""

#: ../lib/pdk/module/build.rb:127
msgid "%{message} Please rename the file or exclude it from the package by adding it to the .pdkignore file in your module."
msgid "%{message} Rename the file or exclude it from the package by adding it to the .pdkignore file in your module."
msgstr ""

#: ../lib/pdk/module/build.rb:155
Expand Down Expand Up @@ -1062,11 +1066,11 @@ msgid "Unable to clone git repository at '%{repo}' into '%{dest}'."
msgstr ""

#: ../lib/pdk/module/templatedir.rb:353
msgid "Unable to set HEAD of git repository at '%{repo}' to ref:'%{ref}'."
msgid "Unable to checkout '%{ref}' of git repository at '%{path}'."
msgstr ""

#: ../lib/pdk/module/templatedir.rb:356
msgid "Uncommitted changes found when attempting to set HEAD of git repository at '%{repo}' to ref '%{ref}'; skipping git reset."
msgid "Uncommitted changes found when attempting to checkout '%{ref}' of git repository at '%{path}'; skipping git reset."
msgstr ""

#: ../lib/pdk/module/update.rb:14
Expand Down Expand Up @@ -1272,11 +1276,11 @@ msgid "Git command failed: git %{args}"
msgstr ""

#: ../lib/pdk/util/git.rb:84
msgid "Unable to locate git work dir \"%{workdir}"
msgid "Unable to locate git work dir \"%{workdir}\""
msgstr ""

#: ../lib/pdk/util/git.rb:85
msgid "Unable to locate git dir \"%{gitdir}"
msgid "Unable to locate git dir \"%{gitdir}\""
msgstr ""

#: ../lib/pdk/util/git.rb:100
Expand All @@ -1292,7 +1296,7 @@ msgid "Unable to find a Puppet gem in current Ruby environment or from Rubygems.
msgstr ""

#: ../lib/pdk/util/puppet_version.rb:59
msgid "Unable to clone git repository at '%{repo}'."
msgid "Unable to clone git repository from '%{repo}'."
msgstr ""

#: ../lib/pdk/util/puppet_version.rb:68
Expand Down Expand Up @@ -1452,7 +1456,7 @@ msgid "Unable to validate Task Metadata. %{error}."
msgstr ""

#: ../lib/pdk/validate/tasks/name.rb:9
msgid "Invalid task name. Task names must start with a lowercase letterand can only contain lowercase letters, numbers, and underscores."
msgid "Invalid task name. Task names must start with a lowercase letter and can only contain lowercase letters, numbers, and underscores."
msgstr ""

#: ../lib/pdk/validate/tasks/name.rb:23
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/pdk/config/value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let(:validator) { ->(_) { true } }

it 'raises an error' do
expect { validate }.to raise_error(ArgumentError, 'validator must be a Hash')
expect { validate }.to raise_error(ArgumentError, '`validator` must be a Hash')
end
end

Expand Down
Loading

0 comments on commit 230d871

Please sign in to comment.