Skip to content

Instantly share code, notes, and snippets.

@levicole
Created April 26, 2011 20:52
Show Gist options
  • Select an option

  • Save levicole/943117 to your computer and use it in GitHub Desktop.

Select an option

Save levicole/943117 to your computer and use it in GitHub Desktop.
I18n helper for vim
"takes whatever you have highlighted in visual mode, you give it a localization key, it inserts that and puts the key plus the phrase in a register for yanking into your locale file.
function! Rlocalize(lk) range
let saved_reg_type = getregtype('"')
let old_reg = getreg('"')
normal! ""gvy
let selection = getreg('"')
let key = split(a:lk, '\.')
let phrase = key[-1].": \"".selection."\""
call setreg('l', phrase, "l")
call setreg('"', old_reg, saved_reg_type)
normal! gvd
exe "normal i t(\"".a:lk."\")"
.s/\(\S\)\s\+/\1 /g
.s/\s\+$//
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment