All Projects → stefanoverna → Vim I18n

stefanoverna / Vim I18n

Vim plugin to easily add I18n translations to your Rails project

Labels

Projects that are alternatives of or similar to Vim I18n

Devbox
Solomon's dev environment
Stars: ✭ 95 (-10.38%)
Mutual labels:  viml
Vim Arduino Syntax
Arduino syntax files for Vim
Stars: ✭ 100 (-5.66%)
Mutual labels:  viml
Tasklist.vim
Eclipse like task list
Stars: ✭ 102 (-3.77%)
Mutual labels:  viml
Preto
A minimal dark theme for VIM.
Stars: ✭ 97 (-8.49%)
Mutual labels:  viml
Vimperator Colors
colorsheme
Stars: ✭ 99 (-6.6%)
Mutual labels:  viml
Vimrc
My vim files (i'm a n00b, don't use these)
Stars: ✭ 100 (-5.66%)
Mutual labels:  viml
Cmd2.vim
cmdline-mode enhancement for Vim
Stars: ✭ 94 (-11.32%)
Mutual labels:  viml
Securemodelines
A secure alternative to Vim modelines
Stars: ✭ 104 (-1.89%)
Mutual labels:  viml
Vim Follow My Lead
Vim plugin for showing all your <Leader> mappings in a readable table including the descriptions.
Stars: ✭ 100 (-5.66%)
Mutual labels:  viml
Vim Luna
Touchdown on Lunar Surface ! :)
Stars: ✭ 102 (-3.77%)
Mutual labels:  viml
Vim Ruby Minitest
Vim highlighting & completion for MiniTest
Stars: ✭ 97 (-8.49%)
Mutual labels:  viml
Elixir.nvim
Vim Completion/Doc/Eval for Elixir (nvim), compile https://github.com/awetzel/neovim-elixir and https://github.com/awetzel/nvim-rplugin
Stars: ✭ 99 (-6.6%)
Mutual labels:  viml
Browser Connect.vim
Live browser interaction for VIM.
Stars: ✭ 101 (-4.72%)
Mutual labels:  viml
Vim Howdoi
A Vim frontend for howdoi, the awesome command line tool that lets you ask what you need and grabs the snippet of code from SO.
Stars: ✭ 96 (-9.43%)
Mutual labels:  viml
Argtextobj.vim
Text-object like motion for arguments
Stars: ✭ 103 (-2.83%)
Mutual labels:  viml
Vip
DEPRECATED - Switch to https://github.com/tobyS/pdv and https://github.com/tobyS/vip instead!
Stars: ✭ 94 (-11.32%)
Mutual labels:  viml
Vim Togglelist
Functions to toggle the [Location List] and the [Quickfix List] windows.
Stars: ✭ 100 (-5.66%)
Mutual labels:  viml
Hermes
An environment for Ruby and JS developers in Darwin
Stars: ✭ 105 (-0.94%)
Mutual labels:  viml
Vim Slack
Slack for Vim client
Stars: ✭ 104 (-1.89%)
Mutual labels:  viml
Vim Hybrid
A dark color scheme for Vim
Stars: ✭ 1,380 (+1201.89%)
Mutual labels:  viml

vim-i18n

Automated translation of Ruby/Rails projects

Introduction

vim-i18n helps you translate your Ruby/Rails project. It just exposes a single function, I18nTranslateString. This function takes the current visual selection, converts it into a I18n.t() call, and adds the proper key in a specified YAML store.

Examples

Extracting translations in .html.erb files

# app/views/users/show.html.erb
<dt>Name</dt>
    ^^^^
    -> Visual select and `:call I18nTranslateString()`

You will be asked for a key. In keeping with Rails translation syntax, if the key begins with . it will be considered a relative key:

# app/views/users/show.html.erb
<dt><%= t('.name') %>

# config/locales/en.yml

en:
  users:
    show:
      name: Name

Extracting translations in .rb files

Say you have the following line in your codebase:

# app/controllers/static_controller.rb
@some_text = "Hello, %{name}!"
             ^^^^^^^^^^^^^^^^^
             -> Visual select this text and `:call I18nTranslateString()`

The plugin will first ask you for the I18n key to use (ie. homepage.greeting). Then, if still not specified, the plugin will ask you the location of the YAML store (ie. config/locales/en.yml).

At this point, the plugin will replace the selection, and add the string to the YAML store:

# app/controllers/static_controller.rb
@some_text = I18n.t('homepage.greeting', name: '')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             -> BOOM!

# config/locales/en.yml
---
en:
  homepage:
    title: "Hello, %{name}!"

Note that the extracted translation included the appropriate interpolation.

Displaying translation for the key

Let say you have the following key within view / model / controller:

# app/controllers/static_controller.rb
@some_text = I18n.t('homepage.greeting', name: '')
                     ^^^^^^^^^^^^^^^^^

After selecting and executing I18nDisplayTranslation(), the plugin will return you value for the translation.

Vim mapping

Add this line or a simliar one to your ~.vimrc:

vmap <Leader>z :call I18nTranslateString()<CR>
vmap <Leader>dt :call I18nDisplayTranslation()<CR>

Installation

Install via pathogen.vim, simply copy and paste:

cd ~/.vim/bundle
git clone git://github.com/stefanoverna/vim-i18n.git
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].