Skip to content

Commit

Permalink
UI methods no longer automatically translate. Makes it easier for plu…
Browse files Browse the repository at this point in the history
…gin developers.
  • Loading branch information
mitchellh committed Sep 22, 2010
1 parent 5316a52 commit d003cc4
Show file tree
Hide file tree
Showing 51 changed files with 85 additions and 106 deletions.
2 changes: 1 addition & 1 deletion bin/vagrant
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ begin
# Kick start the CLI
Vagrant::CLI.start(ARGV, :env => env)
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.backtrace.join("\n"), opts if ENV["VAGRANT_DEBUG"]
exit e.status_code if e.respond_to?(:status_code)
Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def run(callable, options=nil)
# chain has been run.
int_callback = lambda do
if action_environment.interrupted?
env.ui.error "vagrant.actions.runner.exit_immediately"
env.ui.error I18n.t("vagrant.actions.runner.exit_immediately")
abort
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!
@@reported_interrupt = true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/box/destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(app, env)
end

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)

@app.call(env)
Expand Down
6 changes: 3 additions & 3 deletions lib/vagrant/action/box/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def call(env)
def instantiate_downloader
@env["download.classes"].each do |klass|
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)
end
end
Expand All @@ -48,7 +48,7 @@ def download

def recover(env)
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)
end
end
Expand All @@ -64,7 +64,7 @@ def box_temp_path
end

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)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/box/unpackage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setup_box_directory

def decompress
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)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/box/verify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(app, env)

def call(env)
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)
rescue Exception
raise Errors::BoxVerificationFailed.new
Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant/action/general/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def verify_files_to_copy
# the actual box
def copy_include_files
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.cp(from, to)
end
end

# Compress the exported file into a package
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|
Archive::Tar::Minitar::Output.open(tar) do |output|
begin
Expand Down
8 changes: 4 additions & 4 deletions lib/vagrant/action/vm/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ def call(env)
end

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)
end

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|
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
end

Expand All @@ -37,7 +37,7 @@ def wait_for_boot
sleep 5 if !@env["vagrant.test"]
end

@env.ui.error "vagrant.actions.vm.boot.failed"
@env.ui.error I18n.t("vagrant.actions.vm.boot.failed")
false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/check_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def call(env)
box_url = env["config"].vm.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)
env.env.load_box!
end
Expand Down
6 changes: 3 additions & 3 deletions lib/vagrant/action/vm/check_guest_additions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def call(env)
# doesn't support guest properties (due to cross platform issues)
version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
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
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,
:virtualbox_version => VirtualBox.version)
:virtualbox_version => VirtualBox.version))
end

# Continue
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/clear_forwarded_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def call(env)

def clear
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
@env["vm"].reload!
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/clear_shared_folders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def call(env)

def clear_shared_folders
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.each do |shared_folder|
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/customize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(app, env)

def call(env)
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["vm"].vm.save
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(app, env)
end

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 = nil

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/destroy_unused_network_interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def call(env)
# Destroy the network interface if there is only one
# attached VM (which must be this VM)
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
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/disable_networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def call(env)
next if adapter.attachment_type != :host_only

if !logged
env.ui.info "vagrant.actions.vm.disable_networks.disabling"
env.ui.info I18n.t("vagrant.actions.vm.disable_networks.disabling")
logged = true
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/discard_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(app, env)

def call(env)
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
end

Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant/action/vm/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def recover(env)
end

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)
FileUtils.mkpath(@env["export.temp_dir"])
end

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.ui.report_progress(progress.percent, 100, false)
end
Expand Down
10 changes: 5 additions & 5 deletions lib/vagrant/action/vm/forward_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def handle_collision(name, options, existing_ports)
existing_ports << options[:hostport]

# 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,
:new_port => options[:hostport])
:new_port => options[:hostport]))
end

#--------------------------------------------------------------
Expand All @@ -89,7 +89,7 @@ def call(env)
end

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|
adapter = options[:adapter]
Expand All @@ -104,10 +104,10 @@ def forward_ports
# Host-only or Bridged networking don't require port-forwarding and establishing forwarded ports on these
# attachment types has uncertain behaviour.
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)
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

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/halt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call(env)
env["vm"].system.halt if !env["force"]

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
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(app, env)
end

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
env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file.to_s) do |progress|
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/match_mac_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(app, env)
end

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.save

Expand Down
6 changes: 3 additions & 3 deletions lib/vagrant/action/vm/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def call(env)
@app.call(env)

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.env.config.vm.network_options.compact.each do |network_options|
@env["vm"].system.enable_host_only_network(network_options)
Expand Down Expand Up @@ -54,7 +54,7 @@ def enable_network?
# Enables and assigns the host only network to the proper
# adapter on the VM, and saves the adapter.
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|
adapter = @env["vm"].vm.network_adapters[network_options[:adapter]]
Expand Down Expand Up @@ -86,7 +86,7 @@ def network_name(net_options)
raise Errors::NetworkNotFound.new(:name => net_options[:name]) if net_options[:name]

# 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.enable_static(network_ip(net_options[:ip], net_options[:netmask]),
Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant/action/vm/nfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ def prepare_permission(perm, opts)
# involves adding a line to `/etc/exports` for this VM, but it is
# up to the host class to define the specific behavior.
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)
end

# Uses the system class to mount the NFS 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)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant/action/vm/provision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def call(env)
@app.call(env)

if provisioning_enabled?
@env.ui.info "vagrant.actions.vm.provision.beginning"
@env.ui.info I18n.t("vagrant.actions.vm.provision.beginning")
@provisioner.provision!
end
end
Expand All @@ -40,7 +40,7 @@ def load_provisioner
@provisioner = provisioner_klass.new(@env)
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
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/resume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(app, env)

def call(env)
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)
end

Expand Down
8 changes: 4 additions & 4 deletions lib/vagrant/action/vm/share_folders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def shared_folders
end

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|
folder = VirtualBox::SharedFolder.new
Expand All @@ -46,13 +46,13 @@ def create_metadata
end

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|
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,
:guest_path => data[:guestpath])
:guest_path => data[:guestpath]))
@env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath])
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/action/vm/suspend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(app, env)

def call(env)
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
end

Expand Down
Loading

0 comments on commit d003cc4

Please sign in to comment.