A versão 1.1 do Vagrant foi lançada. A documentação que você está lendo é para o Vagrant 1.0.x. Leia mais sobre o Vagrant 1.1 no anúncio de lançamento. Acesse agora a documentação da versão 1.1.

I18n

Vagrant comes setup with the Ruby I18n (internationalization) library, which allows you to store all your strings in a YAML file. While it’s not required, there are many benefits to this:

  1. Easier to maintain the various strings of your plugin
  2. Easy for others to translate your plugin, if they so choose
  3. Removes strings from your code logic, which helps since strings look ugly in the code and clutter the flow of logic.

Again, it’s completely optional, but using it is so easy that is recommended.

Using I18n

First, define your translations in a file, which I typically name en.yml (since it’s for the en locale). It looks like this:

en:
  vagrant:
    plugins:
      my_plugin:
        hello: "Hello, %{name}!"

Once that is defined, you have to add that file to the I18n load path:

I18n.load_path << "/path/to/my/en.yml"

Then, once it’s adding, you can use your translations anywhere you’d like:

I18n.t("vagrant.plugins.my_plugin.hello", :name => "Mitchell")

The second parameter is an optional hash of interpolation variables, which are interpolated into the translation. The %{name} is replaced with the name interpolation variable. If you don’t have any variables to interpolate, you can just omit the parameter.