UI methods no longer automatically translate. Makes it easier for plugin developers.

This commit is contained in:
Mitchell Hashimoto 2010-09-21 18:10:46 -06:00
parent 5316a520c6
commit d003cc4f32
51 changed files with 85 additions and 106 deletions

View File

@ -14,7 +14,7 @@ begin
# Kick start the CLI # Kick start the CLI
Vagrant::CLI.start(ARGV, :env => env) Vagrant::CLI.start(ARGV, :env => env)
rescue Vagrant::Errors::VagrantError => e rescue Vagrant::Errors::VagrantError => e
opts = { :_translate => false, :_prefix => false } opts = { :_prefix => false }
env.ui.error e.message, opts if e.message env.ui.error e.message, opts if e.message
env.ui.error e.backtrace.join("\n"), opts if ENV["VAGRANT_DEBUG"] env.ui.error e.backtrace.join("\n"), opts if ENV["VAGRANT_DEBUG"]
exit e.status_code if e.respond_to?(:status_code) exit e.status_code if e.respond_to?(:status_code)

View File

@ -56,11 +56,11 @@ module Vagrant
# chain has been run. # chain has been run.
int_callback = lambda do int_callback = lambda do
if action_environment.interrupted? if action_environment.interrupted?
env.ui.error "vagrant.actions.runner.exit_immediately" env.ui.error I18n.t("vagrant.actions.runner.exit_immediately")
abort abort
end end
env.ui.warn "vagrant.actions.runner.waiting_cleanup" if !@@reported_interrupt env.ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup") if !@@reported_interrupt
action_environment.interrupt! action_environment.interrupt!
@@reported_interrupt = true @@reported_interrupt = true
end end

View File

@ -10,7 +10,7 @@ module Vagrant
end end
def call(env) def call(env)
env.ui.info "vagrant.actions.box.destroy.destroying", :name => env["box"].name env.ui.info I18n.t("vagrant.actions.box.destroy.destroying", :name => env["box"].name)
FileUtils.rm_rf(env["box"].directory) FileUtils.rm_rf(env["box"].directory)
@app.call(env) @app.call(env)

View File

@ -28,7 +28,7 @@ module Vagrant
def instantiate_downloader def instantiate_downloader
@env["download.classes"].each do |klass| @env["download.classes"].each do |klass|
if klass.match?(@env["box"].uri) if klass.match?(@env["box"].uri)
@env.ui.info "vagrant.actions.box.download.with", :class => klass.to_s @env.ui.info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s)
@downloader = klass.new(@env) @downloader = klass.new(@env)
end end
end end
@ -48,7 +48,7 @@ module Vagrant
def recover(env) def recover(env)
if temp_path && File.exist?(temp_path) if temp_path && File.exist?(temp_path)
env.ui.info "vagrant.actions.box.download.cleaning" env.ui.info I18n.t("vagrant.actions.box.download.cleaning")
File.unlink(temp_path) File.unlink(temp_path)
end end
end end
@ -64,7 +64,7 @@ module Vagrant
end end
def download_to(f) def download_to(f)
@env.ui.info "vagrant.actions.box.download.copying" @env.ui.info I18n.t("vagrant.actions.box.download.copying")
@downloader.download!(@env["box"].uri, f) @downloader.download!(@env["box"].uri, f)
end end
end end

View File

@ -45,7 +45,7 @@ module Vagrant
def decompress def decompress
Dir.chdir(@env["box"].directory) do Dir.chdir(@env["box"].directory) do
@env.ui.info "vagrant.actions.box.unpackage.extracting" @env.ui.info I18n.t("vagrant.actions.box.unpackage.extracting")
Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box"].directory.to_s) Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box"].directory.to_s)
end end
end end

View File

@ -9,7 +9,7 @@ module Vagrant
def call(env) def call(env)
begin begin
env.ui.info "vagrant.actions.box.verify.verifying" env.ui.info I18n.t("vagrant.actions.box.verify.verifying")
VirtualBox::Appliance.new(env["box"].ovf_file.to_s) VirtualBox::Appliance.new(env["box"].ovf_file.to_s)
rescue Exception rescue Exception
raise Errors::BoxVerificationFailed.new raise Errors::BoxVerificationFailed.new

View File

@ -66,7 +66,7 @@ module Vagrant
# the actual box # the actual box
def copy_include_files def copy_include_files
files_to_copy.each do |from, to| files_to_copy.each do |from, to|
@env.ui.info "vagrant.actions.general.package.packaging", :file => from @env.ui.info I18n.t("vagrant.actions.general.package.packaging", :file => from)
FileUtils.mkdir_p(to.parent) FileUtils.mkdir_p(to.parent)
FileUtils.cp(from, to) FileUtils.cp(from, to)
end end
@ -74,7 +74,7 @@ module Vagrant
# Compress the exported file into a package # Compress the exported file into a package
def compress def compress
@env.ui.info "vagrant.actions.general.package.compressing", :tar_path => tar_path @env.ui.info I18n.t("vagrant.actions.general.package.compressing", :tar_path => tar_path)
File.open(tar_path, Platform.tar_file_options) do |tar| File.open(tar_path, Platform.tar_file_options) do |tar|
Archive::Tar::Minitar::Output.open(tar) do |output| Archive::Tar::Minitar::Output.open(tar) do |output|
begin begin

View File

@ -17,16 +17,16 @@ module Vagrant
end end
def boot def boot
@env.ui.info "vagrant.actions.vm.boot.booting" @env.ui.info I18n.t("vagrant.actions.vm.boot.booting")
@env["vm"].vm.start(@env.env.config.vm.boot_mode) @env["vm"].vm.start(@env.env.config.vm.boot_mode)
end end
def wait_for_boot def wait_for_boot
@env.ui.info "vagrant.actions.vm.boot.waiting" @env.ui.info I18n.t("vagrant.actions.vm.boot.waiting")
@env.env.config.ssh.max_tries.to_i.times do |i| @env.env.config.ssh.max_tries.to_i.times do |i|
if @env["vm"].ssh.up? if @env["vm"].ssh.up?
@env.ui.info "vagrant.actions.vm.boot.ready" @env.ui.info I18n.t("vagrant.actions.vm.boot.ready")
return true return true
end end
@ -37,7 +37,7 @@ module Vagrant
sleep 5 if !@env["vagrant.test"] sleep 5 if !@env["vagrant.test"]
end end
@env.ui.error "vagrant.actions.vm.boot.failed" @env.ui.error I18n.t("vagrant.actions.vm.boot.failed")
false false
end end
end end

View File

@ -14,7 +14,7 @@ module Vagrant
box_url = env["config"].vm.box_url box_url = env["config"].vm.box_url
raise Errors::BoxSpecifiedDoesntExist.new(:name => box_name) if !box_url raise Errors::BoxSpecifiedDoesntExist.new(:name => box_name) if !box_url
env.ui.info "vagrant.actions.vm.check_box.not_found", :name => box_name env.ui.info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name)
Vagrant::Box.add(env.env, box_name, box_url) Vagrant::Box.add(env.env, box_name, box_url)
env.env.load_box! env.env.load_box!
end end

View File

@ -14,11 +14,11 @@ module Vagrant
# doesn't support guest properties (due to cross platform issues) # doesn't support guest properties (due to cross platform issues)
version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version") version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
if version.empty? if version.empty?
env.ui.warn "vagrant.actions.vm.check_guest_additions.not_detected" env.ui.warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
elsif version != VirtualBox.version elsif version != VirtualBox.version
env.ui.warn("vagrant.actions.vm.check_guest_additions.version_mismatch", env.ui.warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
:guest_version => version, :guest_version => version,
:virtualbox_version => VirtualBox.version) :virtualbox_version => VirtualBox.version))
end end
# Continue # Continue

View File

@ -19,7 +19,7 @@ module Vagrant
def clear def clear
if used_ports.length > 0 if used_ports.length > 0
@env.ui.info "vagrant.actions.vm.clear_forward_ports.deleting" @env.ui.info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
clear_ports clear_ports
@env["vm"].reload! @env["vm"].reload!
end end

View File

@ -16,7 +16,7 @@ module Vagrant
def clear_shared_folders def clear_shared_folders
if @env["vm"].vm.shared_folders.length > 0 if @env["vm"].vm.shared_folders.length > 0
@env.ui.info "vagrant.actions.vm.clear_shared_folders.deleting" @env.ui.info I18n.t("vagrant.actions.vm.clear_shared_folders.deleting")
folders = @env["vm"].vm.shared_folders.dup folders = @env["vm"].vm.shared_folders.dup
folders.each do |shared_folder| folders.each do |shared_folder|

View File

@ -8,7 +8,7 @@ module Vagrant
def call(env) def call(env)
if !env.env.config.vm.proc_stack.empty? if !env.env.config.vm.proc_stack.empty?
env.ui.info "vagrant.actions.vm.customize.running" env.ui.info I18n.t("vagrant.actions.vm.customize.running")
env.env.config.vm.run_procs!(env["vm"].vm) env.env.config.vm.run_procs!(env["vm"].vm)
env["vm"].vm.save env["vm"].vm.save
end end

View File

@ -7,7 +7,7 @@ module Vagrant
end end
def call(env) def call(env)
env.ui.info "vagrant.actions.vm.destroy.destroying" env.ui.info I18n.t("vagrant.actions.vm.destroy.destroying")
env["vm"].vm.destroy(:destroy_medium => :delete) env["vm"].vm.destroy(:destroy_medium => :delete)
env["vm"].vm = nil env["vm"].vm = nil

View File

@ -21,7 +21,7 @@ module Vagrant
# Destroy the network interface if there is only one # Destroy the network interface if there is only one
# attached VM (which must be this VM) # attached VM (which must be this VM)
if interface.attached_vms.length == 1 if interface.attached_vms.length == 1
env.ui.info "vagrant.actions.vm.destroy_network.destroying" env.ui.info I18n.t("vagrant.actions.vm.destroy_network.destroying")
interface.destroy interface.destroy
end end
end end

View File

@ -17,7 +17,7 @@ module Vagrant
next if adapter.attachment_type != :host_only next if adapter.attachment_type != :host_only
if !logged if !logged
env.ui.info "vagrant.actions.vm.disable_networks.disabling" env.ui.info I18n.t("vagrant.actions.vm.disable_networks.disabling")
logged = true logged = true
end end

View File

@ -10,7 +10,7 @@ module Vagrant
def call(env) def call(env)
if env["vm"].created? && env["vm"].vm.saved? if env["vm"].created? && env["vm"].vm.saved?
env.ui.info "vagrant.actions.vm.discard_state.discarding" env.ui.info I18n.t("vagrant.actions.vm.discard_state.discarding")
env["vm"].vm.discard_state env["vm"].vm.discard_state
end end

View File

@ -31,13 +31,13 @@ module Vagrant
end end
def setup_temp_dir def setup_temp_dir
@env.ui.info "vagrant.actions.vm.export.create_dir" @env.ui.info I18n.t("vagrant.actions.vm.export.create_dir")
@temp_dir = @env["export.temp_dir"] = @env.env.tmp_path.join(Time.now.to_i.to_s) @temp_dir = @env["export.temp_dir"] = @env.env.tmp_path.join(Time.now.to_i.to_s)
FileUtils.mkpath(@env["export.temp_dir"]) FileUtils.mkpath(@env["export.temp_dir"])
end end
def export def export
@env.ui.info "vagrant.actions.vm.export.exporting" @env.ui.info I18n.t("vagrant.actions.vm.export.exporting")
@env["vm"].vm.export(ovf_path) do |progress| @env["vm"].vm.export(ovf_path) do |progress|
@env.ui.report_progress(progress.percent, 100, false) @env.ui.report_progress(progress.percent, 100, false)
end end

View File

@ -72,9 +72,9 @@ module Vagrant
existing_ports << options[:hostport] existing_ports << options[:hostport]
# Notify the user # Notify the user
@env.ui.info("vagrant.actions.vm.forward_ports.fixed_collision", @env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.fixed_collision",
:name => name, :name => name,
:new_port => options[:hostport]) :new_port => options[:hostport]))
end end
#-------------------------------------------------------------- #--------------------------------------------------------------
@ -89,7 +89,7 @@ module Vagrant
end end
def forward_ports def forward_ports
@env.ui.info "vagrant.actions.vm.forward_ports.forwarding" @env.ui.info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
@env.env.config.vm.forwarded_ports.each do |name, options| @env.env.config.vm.forwarded_ports.each do |name, options|
adapter = options[:adapter] adapter = options[:adapter]
@ -104,10 +104,10 @@ module Vagrant
# Host-only or Bridged networking don't require port-forwarding and establishing forwarded ports on these # Host-only or Bridged networking don't require port-forwarding and establishing forwarded ports on these
# attachment types has uncertain behaviour. # attachment types has uncertain behaviour.
if @env["vm"].vm.network_adapters[adapter].attachment_type == :nat if @env["vm"].vm.network_adapters[adapter].attachment_type == :nat
@env.ui.info("vagrant.actions.vm.forward_ports.forwarding_entry", message_attributes) @env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry", message_attributes))
forward_port(name, options) forward_port(name, options)
else else
@env.ui.info("vagrant.actions.vm.forward_ports.non_nat", message_attributes) @env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.non_nat", message_attributes))
end end
end end

View File

@ -12,7 +12,7 @@ module Vagrant
env["vm"].system.halt if !env["force"] env["vm"].system.halt if !env["force"]
if env["vm"].vm.state(true) != :powered_off if env["vm"].vm.state(true) != :powered_off
env.ui.info "vagrant.actions.vm.halt.force" env.ui.info I18n.t("vagrant.actions.vm.halt.force")
env["vm"].vm.stop env["vm"].vm.stop
end end

View File

@ -7,7 +7,7 @@ module Vagrant
end end
def call(env) def call(env)
env.ui.info "vagrant.actions.vm.import.importing", :name => env.env.box.name env.ui.info I18n.t("vagrant.actions.vm.import.importing", :name => env.env.box.name)
# Import the virtual machine # Import the virtual machine
env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file.to_s) do |progress| env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file.to_s) do |progress|

View File

@ -7,7 +7,7 @@ module Vagrant
end end
def call(env) def call(env)
env.ui.info "vagrant.actions.vm.match_mac.matching" env.ui.info I18n.t("vagrant.actions.vm.match_mac.matching")
env["vm"].vm.network_adapters.first.mac_address = env.env.config.vm.base_mac env["vm"].vm.network_adapters.first.mac_address = env.env.config.vm.base_mac
env["vm"].vm.save env["vm"].vm.save

View File

@ -20,7 +20,7 @@ module Vagrant
@app.call(env) @app.call(env)
if enable_network? if enable_network?
@env.ui.info "vagrant.actions.vm.network.enabling" @env.ui.info I18n.t("vagrant.actions.vm.network.enabling")
@env["vm"].system.prepare_host_only_network @env["vm"].system.prepare_host_only_network
@env.env.config.vm.network_options.compact.each do |network_options| @env.env.config.vm.network_options.compact.each do |network_options|
@env["vm"].system.enable_host_only_network(network_options) @env["vm"].system.enable_host_only_network(network_options)
@ -54,7 +54,7 @@ module Vagrant
# Enables and assigns the host only network to the proper # Enables and assigns the host only network to the proper
# adapter on the VM, and saves the adapter. # adapter on the VM, and saves the adapter.
def assign_network def assign_network
@env.ui.info "vagrant.actions.vm.network.preparing" @env.ui.info I18n.t("vagrant.actions.vm.network.preparing")
@env.env.config.vm.network_options.compact.each do |network_options| @env.env.config.vm.network_options.compact.each do |network_options|
adapter = @env["vm"].vm.network_adapters[network_options[:adapter]] adapter = @env["vm"].vm.network_adapters[network_options[:adapter]]
@ -86,7 +86,7 @@ module Vagrant
raise Errors::NetworkNotFound.new(:name => net_options[:name]) if net_options[:name] raise Errors::NetworkNotFound.new(:name => net_options[:name]) if net_options[:name]
# One doesn't exist, create it. # One doesn't exist, create it.
@env.ui.info "vagrant.actions.vm.network.creating" @env.ui.info I18n.t("vagrant.actions.vm.network.creating")
ni = interfaces.create ni = interfaces.create
ni.enable_static(network_ip(net_options[:ip], net_options[:netmask]), ni.enable_static(network_ip(net_options[:ip], net_options[:netmask]),

View File

@ -104,14 +104,14 @@ module Vagrant
# involves adding a line to `/etc/exports` for this VM, but it is # involves adding a line to `/etc/exports` for this VM, but it is
# up to the host class to define the specific behavior. # up to the host class to define the specific behavior.
def export_folders def export_folders
@env.ui.info "vagrant.actions.vm.nfs.exporting" @env.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
@env["host"].nfs_export(guest_ip, folders) @env["host"].nfs_export(guest_ip, folders)
end end
# Uses the system class to mount the NFS folders. # Uses the system class to mount the NFS folders.
def mount_folders def mount_folders
@env.ui.info "vagrant.actions.vm.nfs.mounting" @env.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")
@env["vm"].system.mount_nfs(host_ip, folders) @env["vm"].system.mount_nfs(host_ip, folders)
end end

View File

@ -13,7 +13,7 @@ module Vagrant
@app.call(env) @app.call(env)
if provisioning_enabled? if provisioning_enabled?
@env.ui.info "vagrant.actions.vm.provision.beginning" @env.ui.info I18n.t("vagrant.actions.vm.provision.beginning")
@provisioner.provision! @provisioner.provision!
end end
end end
@ -40,7 +40,7 @@ module Vagrant
@provisioner = provisioner_klass.new(@env) @provisioner = provisioner_klass.new(@env)
end end
@env.ui.info "vagrant.actions.vm.provision.enabled", :provisioner => @provisioner.class.to_s @env.ui.info I18n.t("vagrant.actions.vm.provision.enabled", :provisioner => @provisioner.class.to_s)
@provisioner.prepare @provisioner.prepare
@provisioner @provisioner
end end

View File

@ -8,7 +8,7 @@ module Vagrant
def call(env) def call(env)
if env["vm"].vm.saved? if env["vm"].vm.saved?
env.ui.info "vagrant.actions.vm.resume.resuming" env.ui.info I18n.t("vagrant.actions.vm.resume.resuming")
env["actions"].run(Boot) env["actions"].run(Boot)
end end

View File

@ -33,7 +33,7 @@ module Vagrant
end end
def create_metadata def create_metadata
@env.ui.info "vagrant.actions.vm.share_folders.creating" @env.ui.info I18n.t("vagrant.actions.vm.share_folders.creating")
shared_folders.each do |name, data| shared_folders.each do |name, data|
folder = VirtualBox::SharedFolder.new folder = VirtualBox::SharedFolder.new
@ -46,13 +46,13 @@ module Vagrant
end end
def mount_shared_folders def mount_shared_folders
@env.ui.info "vagrant.actions.vm.share_folders.mounting" @env.ui.info I18n.t("vagrant.actions.vm.share_folders.mounting")
@env["vm"].ssh.execute do |ssh| @env["vm"].ssh.execute do |ssh|
shared_folders.each do |name, data| shared_folders.each do |name, data|
@env.ui.info("vagrant.actions.vm.share_folders.mounting_entry", @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
:name => name, :name => name,
:guest_path => data[:guestpath]) :guest_path => data[:guestpath]))
@env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath]) @env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath])
end end
end end

View File

@ -8,7 +8,7 @@ module Vagrant
def call(env) def call(env)
if env["vm"].vm.running? if env["vm"].vm.running?
env.ui.info "vagrant.actions.vm.suspend.suspending" env.ui.info I18n.t("vagrant.actions.vm.suspend.suspending")
env["vm"].vm.save_state env["vm"].vm.save_state
end end

View File

@ -25,8 +25,8 @@ module Vagrant
desc "list", "Lists all installed boxes" desc "list", "Lists all installed boxes"
def list def list
boxes = env.boxes.sort boxes = env.boxes.sort
return env.ui.warn("vagrant.commands.box.no_installed_boxes", :_prefix => false) if boxes.empty? return env.ui.warn(I18n.t("vagrant.commands.box.no_installed_boxes"), :_prefix => false) if boxes.empty?
boxes.each { |b| env.ui.info(b.name, :_translate => false, :_prefix => false) } boxes.each { |b| env.ui.info(b.name, :_prefix => false) }
end end
end end
end end

View File

@ -8,7 +8,7 @@ module Vagrant
if vm.created? if vm.created?
vm.destroy vm.destroy
else else
vm.env.ui.info "vagrant.commands.common.vm_not_created" vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end end
end end
end end

View File

@ -9,7 +9,7 @@ module Vagrant
if vm.created? if vm.created?
vm.halt(options) vm.halt(options)
else else
vm.env.ui.info "vagrant.commands.common.vm_not_created" vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module Vagrant
if vm.created? && vm.vm.running? if vm.created? && vm.vm.running?
vm.provision vm.provision
else else
vm.env.ui.info "vagrant.commands.common.vm_not_created" vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module Vagrant
if vm.created? if vm.created?
vm.reload vm.reload
else else
vm.env.ui.info "vagrant.commands.common.vm_not_created" vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module Vagrant
if vm.created? if vm.created?
vm.resume vm.resume
else else
vm.env.ui.info "vagrant.commands.common.vm_not_created" vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end end
end end
end end

View File

@ -16,9 +16,9 @@ module Vagrant
def ssh_execute def ssh_execute
ssh_vm.ssh.execute do |ssh| ssh_vm.ssh.execute do |ssh|
ssh_vm.env.ui.info "vagrant.commands.ssh.execute", :command => options[:execute] ssh_vm.env.ui.info I18n.t("vagrant.commands.ssh.execute", :command => options[:execute])
ssh.exec!(options[:execute]) do |channel, type, data| ssh.exec!(options[:execute]) do |channel, type, data|
ssh_vm.env.ui.info "#{data}", :_translate => false ssh_vm.env.ui.info "#{data}"
end end
end end
end end

View File

@ -14,7 +14,7 @@ module Vagrant
:ssh_user => vm.env.config.ssh.username, :ssh_user => vm.env.config.ssh.username,
:ssh_port => vm.ssh.port, :ssh_port => vm.ssh.port,
:private_key_path => vm.env.config.ssh.private_key_path :private_key_path => vm.env.config.ssh.private_key_path
}), :_translate => false, :_prefix => false) }), :_prefix => false)
end end
end end
end end

View File

@ -13,9 +13,9 @@ module Vagrant
state = env.vms.length == 1 ? state : "listing" state = env.vms.length == 1 ? state : "listing"
env.ui.info("vagrant.commands.status.output", env.ui.info(I18n.t("vagrant.commands.status.output",
:states => results.join("\n"), :states => results.join("\n"),
:message => I18n.t("vagrant.commands.status.#{state}"), :message => I18n.t("vagrant.commands.status.#{state}")),
:_prefix => false) :_prefix => false)
end end
end end

View File

@ -8,7 +8,7 @@ module Vagrant
if vm.created? if vm.created?
vm.suspend vm.suspend
else else
vm.env.ui.info "vagrant.commands.common.vm_not_created" vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module Vagrant
# TODO: Make the options[:provision] actually mean something # TODO: Make the options[:provision] actually mean something
target_vms.each do |vm| target_vms.each do |vm|
if vm.created? if vm.created?
vm.env.ui.info "vagrant.commands.up.vm_created" vm.env.ui.info I18n.t("vagrant.commands.up.vm_created")
vm.start vm.start
else else
vm.up vm.up

View File

@ -6,22 +6,22 @@ module Vagrant
register "upgrade_to_060", "Upgrade pre-0.6.0 environment to 0.6.0", :hide => true register "upgrade_to_060", "Upgrade pre-0.6.0 environment to 0.6.0", :hide => true
def execute def execute
@env.ui.warn "vagrant.commands.upgrade_to_060.info", :_prefix => false @env.ui.warn I18n.t("vagrant.commands.upgrade_to_060.info"), :_prefix => false
@env.ui.warn "", :_translate => false, :_prefix => false @env.ui.warn "", :_prefix => false
if !@env.ui.yes? "vagrant.commands.upgrade_to_060.ask", :_prefix => false, :_color => :yellow if !@env.ui.yes? I18n.t("vagrant.commands.upgrade_to_060.ask"), :_prefix => false, :_color => :yellow
@env.ui.info "vagrant.commands.upgrade_to_060.quit", :_prefix => false @env.ui.info I18n.t("vagrant.commands.upgrade_to_060.quit"), :_prefix => false
return return
end end
local_data = @env.local_data local_data = @env.local_data
if !local_data.empty? if !local_data.empty?
if local_data[:active] if local_data[:active]
@env.ui.confirm "vagrant.commands.upgrade_to_060.already_done", :_prefix => false @env.ui.confirm I18n.t("vagrant.commands.upgrade_to_060.already_done"), :_prefix => false
return return
end end
# Backup the previous file # Backup the previous file
@env.ui.info "vagrant.commands.upgrade_to_060.backing_up", :_prefix => false @env.ui.info I18n.t("vagrant.commands.upgrade_to_060.backing_up"), :_prefix => false
FileUtils.cp(local_data.file_path, "#{local_data.file_path}.bak-#{Time.now.to_i}") FileUtils.cp(local_data.file_path, "#{local_data.file_path}.bak-#{Time.now.to_i}")
# Gather the previously set virtual machines into a single # Gather the previously set virtual machines into a single
@ -38,7 +38,7 @@ module Vagrant
local_data.commit local_data.commit
end end
@env.ui.confirm "vagrant.commands.upgrade_to_060.complete", :_prefix => false @env.ui.confirm I18n.t("vagrant.commands.upgrade_to_060.complete"), :_prefix => false
end end
end end
end end

View File

@ -4,8 +4,8 @@ module Vagrant
register "version", "Prints the Vagrant version information", :alias => %w(-v --version) register "version", "Prints the Vagrant version information", :alias => %w(-v --version)
def version def version
env.ui.info("vagrant.commands.version.output", env.ui.info(I18n.t("vagrant.commands.version.output",
:version => Vagrant::VERSION, :version => Vagrant::VERSION),
:_prefix => false) :_prefix => false)
end end
end end

View File

@ -280,7 +280,7 @@ module Vagrant
dirs.each do |dir| dirs.each do |dir|
next if File.directory?(dir) next if File.directory?(dir)
ui.info "vagrant.general.creating_home_dir", :directory => dir ui.info I18n.t("vagrant.general.creating_home_dir", :directory => dir)
FileUtils.mkdir_p(dir) FileUtils.mkdir_p(dir)
end end
end end

View File

@ -19,7 +19,7 @@ module Vagrant
# The sleep ensures that the output is truly flushed before any `sudo` # The sleep ensures that the output is truly flushed before any `sudo`
# commands are issued. # commands are issued.
env.ui.info "vagrant.hosts.bsd.nfs_export.prepare" env.ui.info I18n.t("vagrant.hosts.bsd.nfs_export.prepare")
sleep 0.5 sleep 0.5
output.split("\n").each do |line| output.split("\n").each do |line|

View File

@ -18,7 +18,7 @@ module Vagrant
:ip => ip, :ip => ip,
:folders => folders) :folders => folders)
env.ui.info "vagrant.hosts.linux.nfs_export.prepare" env.ui.info I18n.t("vagrant.hosts.linux.nfs_export.prepare")
sleep 0.5 sleep 0.5
output.split("\n").each do |line| output.split("\n").each do |line|

View File

@ -32,7 +32,7 @@ module Vagrant
end end
def setup_json def setup_json
env.ui.info "vagrant.provisioners.chef.json" env.ui.info I18n.t("vagrant.provisioners.chef.json")
# Set up initial configuration # Set up initial configuration
data = { data = {

View File

@ -22,7 +22,7 @@ module Vagrant
end end
def create_client_key_folder def create_client_key_folder
env.ui.info "vagrant.provisioners.chef.client_key_folder" env.ui.info I18n.t("vagrant.provisioners.chef.client_key_folder")
path = Pathname.new(env.config.chef.client_key_path) path = Pathname.new(env.config.chef.client_key_path)
vm.ssh.execute do |ssh| vm.ssh.execute do |ssh|
@ -31,7 +31,7 @@ module Vagrant
end end
def upload_validation_key def upload_validation_key
env.ui.info "vagrant.provisioners.chef.upload_validation_key" env.ui.info I18n.t("vagrant.provisioners.chef.upload_validation_key")
vm.ssh.upload!(validation_key_path, guest_validation_key_path) vm.ssh.upload!(validation_key_path, guest_validation_key_path)
end end
@ -48,13 +48,13 @@ module Vagrant
def run_chef_client def run_chef_client
command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json" command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json"
env.ui.info "vagrant.provisioners.chef.running_client" env.ui.info I18n.t("vagrant.provisioners.chef.running_client")
vm.ssh.execute do |ssh| vm.ssh.execute do |ssh|
ssh.exec!(command) do |channel, type, data| ssh.exec!(command) do |channel, type, data|
if type == :exit_status if type == :exit_status
ssh.check_exit_status(data, command) ssh.check_exit_status(data, command)
else else
env.ui.info("#{data}: #{type}", :_translate => false) env.ui.info("#{data}: #{type}")
end end
end end
end end

View File

@ -40,11 +40,11 @@ module Vagrant
def run_chef_solo def run_chef_solo
command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json" command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json"
env.ui.info "vagrant.provisioners.chef.running_solo" env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
vm.ssh.execute do |ssh| vm.ssh.execute do |ssh|
ssh.exec!(command) do |channel, type, data| ssh.exec!(command) do |channel, type, data|
ssh.check_exit_status(data, command) if type == :exit_status ssh.check_exit_status(data, command) if type == :exit_status
env.ui.info("#{data}: #{type}", :_translate => false) if type != :exit_status env.ui.info("#{data}: #{type}") if type != :exit_status
end end
end end
end end

View File

@ -28,7 +28,7 @@ module Vagrant
# Overridden methods # Overridden methods
#------------------------------------------------------------------- #-------------------------------------------------------------------
def halt def halt
vm.env.ui.info "vagrant.systems.linux.attempting_halt" vm.env.ui.info I18n.t("vagrant.systems.linux.attempting_halt")
vm.ssh.execute do |ssh| vm.ssh.execute do |ssh|
ssh.exec!("sudo halt") ssh.exec!("sudo halt")
end end

View File

@ -31,7 +31,7 @@ module Vagrant
# #
# does not exist in /etc/user_attr. TODO # does not exist in /etc/user_attr. TODO
def halt def halt
vm.env.ui.info "vagrant.systems.solaris.attempting_halt" vm.env.ui.info I18n.t("vagrant.systems.solaris.attempting_halt")
vm.ssh.execute do |ssh| vm.ssh.execute do |ssh|
ssh.exec!("pfexec poweroff") ssh.exec!("pfexec poweroff")
end end

View File

@ -50,8 +50,7 @@ module Vagrant
protected protected
def format_message(message, opts=nil) def format_message(message, opts=nil)
opts = { :_prefix => true, :_translate => true }.merge(opts || {}) opts = { :_prefix => true }.merge(opts || {})
message = I18n.t(message, opts) if opts[:_translate]
message = "[#{env.resource}] #{message}" if opts[:_prefix] message = "[#{env.resource}] #{message}" if opts[:_prefix]
message message
end end

View File

@ -26,24 +26,4 @@ class ShellUITest < Test::Unit::TestCase
@instance.info("vagrant.errors.test_key", :_prefix => false) @instance.info("vagrant.errors.test_key", :_prefix => false)
end end
end end
context "translating" do
should "translate the message by default" do
@shell.expects(:say).with() do |message, color|
assert message.include?(I18n.t("vagrant.errors.test_key"))
true
end
@instance.info("vagrant.errors.test_key")
end
should "not translate the message if noted" do
@shell.expects(:say).with() do |message, color|
assert message.include?("vagrant.errors.test_key")
true
end
@instance.info("vagrant.errors.test_key", :_translate => false)
end
end
end end