From d003cc4f32915407ff175f5420b35d4405445442 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 21 Sep 2010 18:10:46 -0600 Subject: [PATCH] UI methods no longer automatically translate. Makes it easier for plugin developers. --- bin/vagrant | 2 +- lib/vagrant/action.rb | 4 ++-- lib/vagrant/action/box/destroy.rb | 2 +- lib/vagrant/action/box/download.rb | 6 +++--- lib/vagrant/action/box/unpackage.rb | 2 +- lib/vagrant/action/box/verify.rb | 2 +- lib/vagrant/action/general/package.rb | 4 ++-- lib/vagrant/action/vm/boot.rb | 8 ++++---- lib/vagrant/action/vm/check_box.rb | 2 +- .../action/vm/check_guest_additions.rb | 6 +++--- .../action/vm/clear_forwarded_ports.rb | 2 +- lib/vagrant/action/vm/clear_shared_folders.rb | 2 +- lib/vagrant/action/vm/customize.rb | 2 +- lib/vagrant/action/vm/destroy.rb | 2 +- .../vm/destroy_unused_network_interfaces.rb | 2 +- lib/vagrant/action/vm/disable_networks.rb | 2 +- lib/vagrant/action/vm/discard_state.rb | 2 +- lib/vagrant/action/vm/export.rb | 4 ++-- lib/vagrant/action/vm/forward_ports.rb | 10 +++++----- lib/vagrant/action/vm/halt.rb | 2 +- lib/vagrant/action/vm/import.rb | 2 +- lib/vagrant/action/vm/match_mac_address.rb | 2 +- lib/vagrant/action/vm/network.rb | 6 +++--- lib/vagrant/action/vm/nfs.rb | 4 ++-- lib/vagrant/action/vm/provision.rb | 4 ++-- lib/vagrant/action/vm/resume.rb | 2 +- lib/vagrant/action/vm/share_folders.rb | 8 ++++---- lib/vagrant/action/vm/suspend.rb | 2 +- lib/vagrant/command/box.rb | 4 ++-- lib/vagrant/command/destroy.rb | 2 +- lib/vagrant/command/halt.rb | 2 +- lib/vagrant/command/provision.rb | 2 +- lib/vagrant/command/reload.rb | 2 +- lib/vagrant/command/resume.rb | 2 +- lib/vagrant/command/ssh.rb | 4 ++-- lib/vagrant/command/ssh_config.rb | 2 +- lib/vagrant/command/status.rb | 4 ++-- lib/vagrant/command/suspend.rb | 2 +- lib/vagrant/command/up.rb | 2 +- lib/vagrant/command/upgrade_to_060.rb | 14 ++++++------- lib/vagrant/command/version.rb | 4 ++-- lib/vagrant/environment.rb | 2 +- lib/vagrant/hosts/bsd.rb | 2 +- lib/vagrant/hosts/linux.rb | 2 +- lib/vagrant/provisioners/chef.rb | 2 +- lib/vagrant/provisioners/chef_server.rb | 8 ++++---- lib/vagrant/provisioners/chef_solo.rb | 4 ++-- lib/vagrant/systems/linux.rb | 2 +- lib/vagrant/systems/solaris.rb | 2 +- lib/vagrant/ui.rb | 3 +-- test/vagrant/ui_test.rb | 20 ------------------- 51 files changed, 85 insertions(+), 106 deletions(-) diff --git a/bin/vagrant b/bin/vagrant index 31bb4ca93..9b983c7f3 100755 --- a/bin/vagrant +++ b/bin/vagrant @@ -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) diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 98c390ae2..c43e4bcec 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -56,11 +56,11 @@ module Vagrant # 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 diff --git a/lib/vagrant/action/box/destroy.rb b/lib/vagrant/action/box/destroy.rb index dfe6767dd..005affda9 100644 --- a/lib/vagrant/action/box/destroy.rb +++ b/lib/vagrant/action/box/destroy.rb @@ -10,7 +10,7 @@ module Vagrant 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) diff --git a/lib/vagrant/action/box/download.rb b/lib/vagrant/action/box/download.rb index db50c9c00..7b0774594 100644 --- a/lib/vagrant/action/box/download.rb +++ b/lib/vagrant/action/box/download.rb @@ -28,7 +28,7 @@ module Vagrant 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 @@ -48,7 +48,7 @@ module Vagrant 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 @@ -64,7 +64,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/box/unpackage.rb b/lib/vagrant/action/box/unpackage.rb index 2b4f436ac..00f5bbbb3 100644 --- a/lib/vagrant/action/box/unpackage.rb +++ b/lib/vagrant/action/box/unpackage.rb @@ -45,7 +45,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/box/verify.rb b/lib/vagrant/action/box/verify.rb index 196003236..40ed305f2 100644 --- a/lib/vagrant/action/box/verify.rb +++ b/lib/vagrant/action/box/verify.rb @@ -9,7 +9,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/general/package.rb b/lib/vagrant/action/general/package.rb index 438647df1..8dc5da016 100644 --- a/lib/vagrant/action/general/package.rb +++ b/lib/vagrant/action/general/package.rb @@ -66,7 +66,7 @@ module Vagrant # 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 @@ -74,7 +74,7 @@ module Vagrant # 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 diff --git a/lib/vagrant/action/vm/boot.rb b/lib/vagrant/action/vm/boot.rb index f969b34ad..ed801f538 100644 --- a/lib/vagrant/action/vm/boot.rb +++ b/lib/vagrant/action/vm/boot.rb @@ -17,16 +17,16 @@ module Vagrant 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 @@ -37,7 +37,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/check_box.rb b/lib/vagrant/action/vm/check_box.rb index 1e4a8abc0..c7e3befb6 100644 --- a/lib/vagrant/action/vm/check_box.rb +++ b/lib/vagrant/action/vm/check_box.rb @@ -14,7 +14,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/check_guest_additions.rb b/lib/vagrant/action/vm/check_guest_additions.rb index 34a2c308d..5a053647e 100644 --- a/lib/vagrant/action/vm/check_guest_additions.rb +++ b/lib/vagrant/action/vm/check_guest_additions.rb @@ -14,11 +14,11 @@ module Vagrant # 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 diff --git a/lib/vagrant/action/vm/clear_forwarded_ports.rb b/lib/vagrant/action/vm/clear_forwarded_ports.rb index 452c6d7cb..81ba48cd6 100644 --- a/lib/vagrant/action/vm/clear_forwarded_ports.rb +++ b/lib/vagrant/action/vm/clear_forwarded_ports.rb @@ -19,7 +19,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/clear_shared_folders.rb b/lib/vagrant/action/vm/clear_shared_folders.rb index f088ebdde..c3988ca2e 100644 --- a/lib/vagrant/action/vm/clear_shared_folders.rb +++ b/lib/vagrant/action/vm/clear_shared_folders.rb @@ -16,7 +16,7 @@ module Vagrant 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| diff --git a/lib/vagrant/action/vm/customize.rb b/lib/vagrant/action/vm/customize.rb index 4cfd4d1f6..a7f05f8ae 100644 --- a/lib/vagrant/action/vm/customize.rb +++ b/lib/vagrant/action/vm/customize.rb @@ -8,7 +8,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/destroy.rb b/lib/vagrant/action/vm/destroy.rb index db19f2220..eb9bba409 100644 --- a/lib/vagrant/action/vm/destroy.rb +++ b/lib/vagrant/action/vm/destroy.rb @@ -7,7 +7,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb b/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb index 4af66a947..66b903146 100644 --- a/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +++ b/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb @@ -21,7 +21,7 @@ module Vagrant # 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 diff --git a/lib/vagrant/action/vm/disable_networks.rb b/lib/vagrant/action/vm/disable_networks.rb index c6e0244bf..d8764d6dc 100644 --- a/lib/vagrant/action/vm/disable_networks.rb +++ b/lib/vagrant/action/vm/disable_networks.rb @@ -17,7 +17,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/discard_state.rb b/lib/vagrant/action/vm/discard_state.rb index ad56b6a02..6802ab1a8 100644 --- a/lib/vagrant/action/vm/discard_state.rb +++ b/lib/vagrant/action/vm/discard_state.rb @@ -10,7 +10,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/export.rb b/lib/vagrant/action/vm/export.rb index 258d2c4e7..98f6ffe84 100644 --- a/lib/vagrant/action/vm/export.rb +++ b/lib/vagrant/action/vm/export.rb @@ -31,13 +31,13 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/forward_ports.rb b/lib/vagrant/action/vm/forward_ports.rb index 7959118d0..d8a59e472 100644 --- a/lib/vagrant/action/vm/forward_ports.rb +++ b/lib/vagrant/action/vm/forward_ports.rb @@ -72,9 +72,9 @@ module Vagrant 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 #-------------------------------------------------------------- @@ -89,7 +89,7 @@ module Vagrant 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] @@ -104,10 +104,10 @@ module Vagrant # 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 diff --git a/lib/vagrant/action/vm/halt.rb b/lib/vagrant/action/vm/halt.rb index ef578fa13..935627a7c 100644 --- a/lib/vagrant/action/vm/halt.rb +++ b/lib/vagrant/action/vm/halt.rb @@ -12,7 +12,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/import.rb b/lib/vagrant/action/vm/import.rb index 1396e15b8..33e781a2f 100644 --- a/lib/vagrant/action/vm/import.rb +++ b/lib/vagrant/action/vm/import.rb @@ -7,7 +7,7 @@ module Vagrant 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| diff --git a/lib/vagrant/action/vm/match_mac_address.rb b/lib/vagrant/action/vm/match_mac_address.rb index 44332cab0..b64cfd783 100644 --- a/lib/vagrant/action/vm/match_mac_address.rb +++ b/lib/vagrant/action/vm/match_mac_address.rb @@ -7,7 +7,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/network.rb b/lib/vagrant/action/vm/network.rb index c9ca0969e..0236b8535 100644 --- a/lib/vagrant/action/vm/network.rb +++ b/lib/vagrant/action/vm/network.rb @@ -20,7 +20,7 @@ module Vagrant @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) @@ -54,7 +54,7 @@ module Vagrant # 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]] @@ -86,7 +86,7 @@ module Vagrant 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]), diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index c50bcf033..193b5b933 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -104,14 +104,14 @@ module Vagrant # 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 diff --git a/lib/vagrant/action/vm/provision.rb b/lib/vagrant/action/vm/provision.rb index 7150c3e7d..b8771746e 100644 --- a/lib/vagrant/action/vm/provision.rb +++ b/lib/vagrant/action/vm/provision.rb @@ -13,7 +13,7 @@ module Vagrant @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 @@ -40,7 +40,7 @@ module Vagrant @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 diff --git a/lib/vagrant/action/vm/resume.rb b/lib/vagrant/action/vm/resume.rb index 7177f1d10..b3d2b265a 100644 --- a/lib/vagrant/action/vm/resume.rb +++ b/lib/vagrant/action/vm/resume.rb @@ -8,7 +8,7 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index cea5328f9..36bd451a6 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -33,7 +33,7 @@ module Vagrant 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 @@ -46,13 +46,13 @@ module Vagrant 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 diff --git a/lib/vagrant/action/vm/suspend.rb b/lib/vagrant/action/vm/suspend.rb index 47cf32d53..309a8e737 100644 --- a/lib/vagrant/action/vm/suspend.rb +++ b/lib/vagrant/action/vm/suspend.rb @@ -8,7 +8,7 @@ module Vagrant 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 diff --git a/lib/vagrant/command/box.rb b/lib/vagrant/command/box.rb index 04ce2e8af..8df80f52a 100644 --- a/lib/vagrant/command/box.rb +++ b/lib/vagrant/command/box.rb @@ -25,8 +25,8 @@ module Vagrant desc "list", "Lists all installed boxes" def list boxes = env.boxes.sort - return env.ui.warn("vagrant.commands.box.no_installed_boxes", :_prefix => false) if boxes.empty? - boxes.each { |b| env.ui.info(b.name, :_translate => false, :_prefix => false) } + 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, :_prefix => false) } end end end diff --git a/lib/vagrant/command/destroy.rb b/lib/vagrant/command/destroy.rb index d791e9f3a..a672c0f24 100644 --- a/lib/vagrant/command/destroy.rb +++ b/lib/vagrant/command/destroy.rb @@ -8,7 +8,7 @@ module Vagrant if vm.created? vm.destroy 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 diff --git a/lib/vagrant/command/halt.rb b/lib/vagrant/command/halt.rb index 5918387fc..3b4d6f85a 100644 --- a/lib/vagrant/command/halt.rb +++ b/lib/vagrant/command/halt.rb @@ -9,7 +9,7 @@ module Vagrant if vm.created? vm.halt(options) 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 diff --git a/lib/vagrant/command/provision.rb b/lib/vagrant/command/provision.rb index dd3320290..4c797f61a 100644 --- a/lib/vagrant/command/provision.rb +++ b/lib/vagrant/command/provision.rb @@ -8,7 +8,7 @@ module Vagrant if vm.created? && vm.vm.running? vm.provision 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 diff --git a/lib/vagrant/command/reload.rb b/lib/vagrant/command/reload.rb index df72ddda6..e359cb6c8 100644 --- a/lib/vagrant/command/reload.rb +++ b/lib/vagrant/command/reload.rb @@ -8,7 +8,7 @@ module Vagrant if vm.created? vm.reload 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 diff --git a/lib/vagrant/command/resume.rb b/lib/vagrant/command/resume.rb index d76790f36..be9171954 100644 --- a/lib/vagrant/command/resume.rb +++ b/lib/vagrant/command/resume.rb @@ -8,7 +8,7 @@ module Vagrant if vm.created? vm.resume 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 diff --git a/lib/vagrant/command/ssh.rb b/lib/vagrant/command/ssh.rb index b5d03a91c..31e11f07a 100644 --- a/lib/vagrant/command/ssh.rb +++ b/lib/vagrant/command/ssh.rb @@ -16,9 +16,9 @@ module Vagrant def ssh_execute 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_vm.env.ui.info "#{data}", :_translate => false + ssh_vm.env.ui.info "#{data}" end end end diff --git a/lib/vagrant/command/ssh_config.rb b/lib/vagrant/command/ssh_config.rb index 645097148..92d70bd67 100644 --- a/lib/vagrant/command/ssh_config.rb +++ b/lib/vagrant/command/ssh_config.rb @@ -14,7 +14,7 @@ module Vagrant :ssh_user => vm.env.config.ssh.username, :ssh_port => vm.ssh.port, :private_key_path => vm.env.config.ssh.private_key_path - }), :_translate => false, :_prefix => false) + }), :_prefix => false) end end end diff --git a/lib/vagrant/command/status.rb b/lib/vagrant/command/status.rb index d5ba6f8af..c4325cb73 100644 --- a/lib/vagrant/command/status.rb +++ b/lib/vagrant/command/status.rb @@ -13,9 +13,9 @@ module Vagrant 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"), - :message => I18n.t("vagrant.commands.status.#{state}"), + :message => I18n.t("vagrant.commands.status.#{state}")), :_prefix => false) end end diff --git a/lib/vagrant/command/suspend.rb b/lib/vagrant/command/suspend.rb index e63327768..a590d16cd 100644 --- a/lib/vagrant/command/suspend.rb +++ b/lib/vagrant/command/suspend.rb @@ -8,7 +8,7 @@ module Vagrant if vm.created? vm.suspend 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 diff --git a/lib/vagrant/command/up.rb b/lib/vagrant/command/up.rb index 74cac6a96..9b29292ba 100644 --- a/lib/vagrant/command/up.rb +++ b/lib/vagrant/command/up.rb @@ -8,7 +8,7 @@ module Vagrant # TODO: Make the options[:provision] actually mean something target_vms.each do |vm| 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 else vm.up diff --git a/lib/vagrant/command/upgrade_to_060.rb b/lib/vagrant/command/upgrade_to_060.rb index a9d480838..3820e7a4c 100644 --- a/lib/vagrant/command/upgrade_to_060.rb +++ b/lib/vagrant/command/upgrade_to_060.rb @@ -6,22 +6,22 @@ module Vagrant register "upgrade_to_060", "Upgrade pre-0.6.0 environment to 0.6.0", :hide => true def execute - @env.ui.warn "vagrant.commands.upgrade_to_060.info", :_prefix => false - @env.ui.warn "", :_translate => false, :_prefix => false - if !@env.ui.yes? "vagrant.commands.upgrade_to_060.ask", :_prefix => false, :_color => :yellow - @env.ui.info "vagrant.commands.upgrade_to_060.quit", :_prefix => false + @env.ui.warn I18n.t("vagrant.commands.upgrade_to_060.info"), :_prefix => false + @env.ui.warn "", :_prefix => false + if !@env.ui.yes? I18n.t("vagrant.commands.upgrade_to_060.ask"), :_prefix => false, :_color => :yellow + @env.ui.info I18n.t("vagrant.commands.upgrade_to_060.quit"), :_prefix => false return end local_data = @env.local_data if !local_data.empty? 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 end # 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}") # Gather the previously set virtual machines into a single @@ -38,7 +38,7 @@ module Vagrant local_data.commit 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 diff --git a/lib/vagrant/command/version.rb b/lib/vagrant/command/version.rb index 324751905..53b312e13 100644 --- a/lib/vagrant/command/version.rb +++ b/lib/vagrant/command/version.rb @@ -4,8 +4,8 @@ module Vagrant register "version", "Prints the Vagrant version information", :alias => %w(-v --version) def version - env.ui.info("vagrant.commands.version.output", - :version => Vagrant::VERSION, + env.ui.info(I18n.t("vagrant.commands.version.output", + :version => Vagrant::VERSION), :_prefix => false) end end diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 7255d2f99..ed46d3c5a 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -280,7 +280,7 @@ module Vagrant dirs.each do |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) end end diff --git a/lib/vagrant/hosts/bsd.rb b/lib/vagrant/hosts/bsd.rb index 7d63c4b91..9bf3f2310 100644 --- a/lib/vagrant/hosts/bsd.rb +++ b/lib/vagrant/hosts/bsd.rb @@ -19,7 +19,7 @@ module Vagrant # The sleep ensures that the output is truly flushed before any `sudo` # 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 output.split("\n").each do |line| diff --git a/lib/vagrant/hosts/linux.rb b/lib/vagrant/hosts/linux.rb index 1d9706f2d..68466491e 100644 --- a/lib/vagrant/hosts/linux.rb +++ b/lib/vagrant/hosts/linux.rb @@ -18,7 +18,7 @@ module Vagrant :ip => ip, :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 output.split("\n").each do |line| diff --git a/lib/vagrant/provisioners/chef.rb b/lib/vagrant/provisioners/chef.rb index cd27a2c55..b98e2018d 100644 --- a/lib/vagrant/provisioners/chef.rb +++ b/lib/vagrant/provisioners/chef.rb @@ -32,7 +32,7 @@ module Vagrant end def setup_json - env.ui.info "vagrant.provisioners.chef.json" + env.ui.info I18n.t("vagrant.provisioners.chef.json") # Set up initial configuration data = { diff --git a/lib/vagrant/provisioners/chef_server.rb b/lib/vagrant/provisioners/chef_server.rb index 2a67fb5d2..9ac3578cc 100644 --- a/lib/vagrant/provisioners/chef_server.rb +++ b/lib/vagrant/provisioners/chef_server.rb @@ -22,7 +22,7 @@ module Vagrant end 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) vm.ssh.execute do |ssh| @@ -31,7 +31,7 @@ module Vagrant end 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) end @@ -48,13 +48,13 @@ module Vagrant def run_chef_client 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| ssh.exec!(command) do |channel, type, data| if type == :exit_status ssh.check_exit_status(data, command) else - env.ui.info("#{data}: #{type}", :_translate => false) + env.ui.info("#{data}: #{type}") end end end diff --git a/lib/vagrant/provisioners/chef_solo.rb b/lib/vagrant/provisioners/chef_solo.rb index 73489eb53..d152e9c4e 100644 --- a/lib/vagrant/provisioners/chef_solo.rb +++ b/lib/vagrant/provisioners/chef_solo.rb @@ -40,11 +40,11 @@ module Vagrant def run_chef_solo 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| ssh.exec!(command) do |channel, type, data| 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 diff --git a/lib/vagrant/systems/linux.rb b/lib/vagrant/systems/linux.rb index a05ebc374..a36ae49ad 100644 --- a/lib/vagrant/systems/linux.rb +++ b/lib/vagrant/systems/linux.rb @@ -28,7 +28,7 @@ module Vagrant # Overridden methods #------------------------------------------------------------------- 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| ssh.exec!("sudo halt") end diff --git a/lib/vagrant/systems/solaris.rb b/lib/vagrant/systems/solaris.rb index c4a08905e..cf5692a85 100644 --- a/lib/vagrant/systems/solaris.rb +++ b/lib/vagrant/systems/solaris.rb @@ -31,7 +31,7 @@ module Vagrant # # does not exist in /etc/user_attr. TODO 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| ssh.exec!("pfexec poweroff") end diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 7e6d9d7eb..393c2b2ae 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -50,8 +50,7 @@ module Vagrant protected def format_message(message, opts=nil) - opts = { :_prefix => true, :_translate => true }.merge(opts || {}) - message = I18n.t(message, opts) if opts[:_translate] + opts = { :_prefix => true }.merge(opts || {}) message = "[#{env.resource}] #{message}" if opts[:_prefix] message end diff --git a/test/vagrant/ui_test.rb b/test/vagrant/ui_test.rb index 72802344f..cdd1fba7d 100644 --- a/test/vagrant/ui_test.rb +++ b/test/vagrant/ui_test.rb @@ -26,24 +26,4 @@ class ShellUITest < Test::Unit::TestCase @instance.info("vagrant.errors.test_key", :_prefix => false) 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