Move to I18n
This commit is contained in:
parent
958ce8983b
commit
beb84d3212
|
@ -36,27 +36,21 @@ module VagrantPlugins
|
|||
# Vagrant::Action::Builtin::CheckRunning)
|
||||
|
||||
if !vm.provider.capability?(:forwarded_ports)
|
||||
@env.ui.error <<-EOH.strip
|
||||
The #{vm.provider_name} provider does not support listing forwarded ports. This
|
||||
is most likely a limitation of the provider and not a bug in Vagrant. If you
|
||||
believe this is a bug in Vagrant, please search existing issues before opening
|
||||
a new one.
|
||||
EOH
|
||||
@env.ui.error(I18n.t("port_command.missing_capability",
|
||||
provider: vm.provider_name,
|
||||
))
|
||||
return 1
|
||||
end
|
||||
|
||||
ports = vm.provider.capability(:forwarded_ports)
|
||||
|
||||
if ports.empty?
|
||||
@env.ui.info("The machine has no configured forwarded ports")
|
||||
@env.ui.info(I18n.t("port_command.empty_ports"))
|
||||
return 0
|
||||
end
|
||||
|
||||
@env.ui.info <<-EOH
|
||||
The forwarded ports for the machine are listed below. Please note that these
|
||||
values may differ from values configured in the Vagrantfile if the provider
|
||||
supports automatic port collision detection and resolution.
|
||||
EOH
|
||||
@env.ui.info(I18n.t("port_command.details"))
|
||||
@env.ui.info("")
|
||||
ports.each do |guest, host|
|
||||
@env.ui.info("#{guest.to_s.rjust(6)} (guest) => #{host} (host)")
|
||||
@env.ui.machine("forwarded_port", guest, host, target: vm.name.to_s)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
en:
|
||||
port_command:
|
||||
details: |-
|
||||
The forwarded ports for the machine are listed below. Please note that
|
||||
these values may differ from values configured in the Vagrantfile if the
|
||||
provider supports automatic port collision detection and resolution.
|
||||
empty_ports: |-
|
||||
The provider reported there are no forwarded ports for this virtual
|
||||
machine. This can be caused if there are no ports specified in the
|
||||
Vagrantfile or if the virtual machine is not currently running. Please
|
||||
check that the virtual machine is running and try again.
|
||||
missing_capability: |-
|
||||
The %{provider} provider does not support listing forwarded ports. This is
|
||||
most likely a limitation of the provider and not a bug in Vagrant. If you
|
||||
believe this is a bug in Vagrant, please search existing issues before
|
||||
opening a new one.
|
|
@ -9,9 +9,19 @@ module VagrantPlugins
|
|||
DESC
|
||||
|
||||
command("port") do
|
||||
require File.expand_path("../command", __FILE__)
|
||||
require_relative "command"
|
||||
self.init!
|
||||
Command
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def self.init!
|
||||
return if defined?(@_init)
|
||||
I18n.load_path << File.expand_path("../locales/en.yml", __FILE__)
|
||||
I18n.reload!
|
||||
@_init = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,11 @@ describe VagrantPlugins::CommandPort::Command do
|
|||
|
||||
let(:machine) { env.machine(env.machine_names[0], :dummy) }
|
||||
|
||||
before(:all) do
|
||||
I18n.load_path << Vagrant.source_root.join("plugins/commands/port/locales/en.yml")
|
||||
I18n.reload!
|
||||
end
|
||||
|
||||
subject { described_class.new(argv, env) }
|
||||
|
||||
before do
|
||||
|
@ -51,7 +56,7 @@ describe VagrantPlugins::CommandPort::Command do
|
|||
it "ensures the vm is running" do
|
||||
allow(state).to receive(:id).and_return(:stopped)
|
||||
expect(env.ui).to receive(:error).with { |message, _|
|
||||
expect(message).to include("make this a better error")
|
||||
expect(message).to include("does not support listing forwarded ports")
|
||||
}
|
||||
|
||||
expect(subject.execute).to eq(1)
|
||||
|
@ -72,7 +77,7 @@ describe VagrantPlugins::CommandPort::Command do
|
|||
.and_return([])
|
||||
|
||||
expect(env.ui).to receive(:info).with { |message, _|
|
||||
expect(message).to include("has no configured forwarded ports")
|
||||
expect(message).to include("there are no forwarded ports")
|
||||
}
|
||||
|
||||
expect(subject.execute).to eq(0)
|
||||
|
|
Loading…
Reference in New Issue