From 671bd55cea3e24892fb8251b58124d8f7c017c78 Mon Sep 17 00:00:00 2001 From: Sergey Leschenko Date: Thu, 20 Oct 2016 13:39:33 +0300 Subject: [PATCH] Make code similar to other providers --- lib/vagrant-lxc/plugin.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/vagrant-lxc/plugin.rb b/lib/vagrant-lxc/plugin.rb index b8ac0cf..55bec55 100644 --- a/lib/vagrant-lxc/plugin.rb +++ b/lib/vagrant-lxc/plugin.rb @@ -8,27 +8,22 @@ module Vagrant The LXC provider allows Vagrant to manage and control LXC-based virtual machines. EOF - locale_loaded = false provider(:lxc, parallel: true, priority: 7) do require File.expand_path("../provider", __FILE__) - - if not locale_loaded - I18n.load_path << File.expand_path(File.dirname(__FILE__) + '/../../locales/en.yml') - I18n.reload! - locale_loaded = true - end - + init! Provider end command "lxc" do require_relative 'command/root' + init! Command::Root end config(:lxc, :provider) do require File.expand_path("../config", __FILE__) + init! Config end @@ -41,6 +36,16 @@ module Vagrant require_relative "provider/cap/public_address" Provider::Cap::PublicAddress end + + protected + + def self.init! + return if defined?(@_init) + I18n.load_path << File.expand_path(File.dirname(__FILE__) + '/../../locales/en.yml') + I18n.reload! + @_init = true + end + end end end