Skip to content

timhwang21/vim-i18next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-i18next

asciinema

This plugin allows for navigating to the internationalized value of a translation key.

While this was written when i18next in mind, it will allow you to jump to arbitrary dot-delimited paths in a specified JSON file.

Requirements

Quick Start

# Install GNU sed
brew install gsed
" Install plugin and dependencies (in this example using vim-plug)
Plug 'timhwang21/vim-i18next'
Plug 'mogelbrod/vim-jsonpath'

" Set path to locale file
let g:i18next_locale_path = '/path/to/file.json'
" If you have different locale files for different areas of the codebase, you
" can use autocmd to set the path based on the current file
autocmd BufRead,BufNewFile /path/to/project/client/*.tsx
/ let g:i18next_local_path = '/app/assets/locales/translation.en-US.json'
autocmd BufRead,BufNewFile /path/to/project/server/*.rb
/ let g:i18next_local_path = '/config/locales/en-US.json'

" Usage
" Print translation value
call i18next#echo('your.search.path')
" Go to translation value
call i18next#goto('your.search.path')
" Print translation value for key on current line
call i18next#echo_cursorline()
" Go to translation value for key on current line
call i18next#goto_cursorline()

" Example mappings
nmap gt :call i18next#goto_cursorline()<CR>
nmap <leader>t :call i18next#echo_cursorline()<CR>
" Example mappings using vim-toop
" This allows operating on text objects for flexibility
" gti' will run the function on the string within single quotes
call toop#mapFunction('i18next#goto', gt)
call toop#mapFunction('i18next#echo', <leader>t)

See :help i18next for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published